npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bupkis/from-assert

v0.1.1

Published

Migrate node:assert assertions to bupkis

Downloads

22

Readme

@bupkis/from-assert

Migrate node:assert assertions to bupkis with a single command.

Supports both strict mode (node:assert/strict) and legacy mode (node:assert) assertions.

Installation

npx @bupkis/from-assert

Or install locally:

npm install -D @bupkis/from-assert

Usage

CLI

# Transform all test files in current directory
npx bupkis-from-assert

# Transform specific patterns
npx bupkis-from-assert "src/**/*.test.ts" "test/**/*.spec.ts"

# Dry run (see what would change without writing)
npx bupkis-from-assert --dry-run

# Exclude patterns
npx bupkis-from-assert --exclude "**/fixtures/**"

# Strict mode (fail on any unsupported assertion)
npx bupkis-from-assert --strict

Programmatic API

import { transform, transformCode } from '@bupkis/from-assert';

// Transform a code string
const { code, transformCount, warnings } = await transformCode(`
  import assert from 'node:assert';
  assert.strictEqual(foo, bar);
`);
// Result: "import { expect } from 'bupkis';\nexpect(foo, 'to be', bar);"

// Transform files
const result = await transform({
  include: ['**/*.test.ts'],
  exclude: ['**/node_modules/**'],
  mode: 'best-effort',
  write: true,
});

Transformations

Strict Equality

| node:assert | bupkis | | --------------------------------- | ----------------------------------- | | assert.strictEqual(a, b) | expect(a, 'to be', b) | | assert.notStrictEqual(a, b) | expect(a, 'not to be', b) | | assert.deepStrictEqual(a, b) | expect(a, 'to deep equal', b) | | assert.notDeepStrictEqual(a, b) | expect(a, 'not to deep equal', b) |

Legacy Equality (with warning)

When using plain node:assert (legacy mode), loose equality assertions are transformed with a warning since behavior may differ:

| node:assert | bupkis | | --------------------------- | ----------------------------------- | | assert.equal(a, b) | expect(a, 'to be', b) ⚠️ | | assert.notEqual(a, b) | expect(a, 'not to be', b) ⚠️ | | assert.deepEqual(a, b) | expect(a, 'to deep equal', b) | | assert.notDeepEqual(a, b) | expect(a, 'not to deep equal', b) |

Truthiness

| node:assert | bupkis | | ------------------ | ------------------------------- | | assert(value) | expect(value, 'to be truthy') | | assert.ok(value) | expect(value, 'to be truthy') |

Throws

| node:assert | bupkis | | ---------------------------- | --------------------------------- | | assert.throws(fn) | expect(fn, 'to throw') | | assert.throws(fn, Error) | expect(fn, 'to throw', Error) | | assert.throws(fn, /regex/) | expect(fn, 'to throw', /regex/) | | assert.doesNotThrow(fn) | expect(fn, 'not to throw') |

Async Assertions

Async assertions use expectAsync:

| node:assert | bupkis | | -------------------------------- | ----------------------------------------------- | | assert.rejects(asyncFn) | expectAsync(asyncFn, 'to reject') | | assert.rejects(asyncFn, Error) | expectAsync(asyncFn, 'to reject with', Error) | | assert.doesNotReject(asyncFn) | expectAsync(asyncFn, 'not to reject') |

String Matching

| node:assert | bupkis | | ----------------------------------- | -------------------------------------- | | assert.match(str, /regex/) | expect(str, 'to match', /regex/) | | assert.doesNotMatch(str, /regex/) | expect(str, 'not to match', /regex/) |

Fail

| node:assert | bupkis | | ---------------------- | ---------------------- | | assert.fail() | expect.fail() | | assert.fail(message) | expect.fail(message) |

Unsupported

The following require manual migration:

  • assert.ifError(value) - Semantics don't map cleanly
  • assert.CallTracker - Deprecated; use @bupkis/sinon instead
  • Complex error matchers with validation functions

Import Handling

The transformer automatically handles all node:assert import styles:

// All of these are transformed
import assert from 'node:assert';
import assert from 'node:assert/strict';
import assert from 'assert';
import assert from 'assert/strict';
import { strict as assert } from 'node:assert';

The import is replaced with:

import { expect } from 'bupkis';
// or, if async assertions are present:
import { expect, expectAsync } from 'bupkis';

Options

| Option | Description | | ----------------- | ---------------------------------------------------------------- | | --dry-run | Show what would change without writing files | | --strict | Fail on any unsupported assertion | | --best-effort | Transform what we can, return warnings for unsupported (default) | | --exclude, -e | Patterns to exclude (default: **/node_modules/**) |

Handling Unsupported Assertions

In best-effort mode (default), unsupported assertions are left unchanged and a warning is returned. Search for warnings in the output to find items requiring manual review.

License

Blue Oak Model License 1.0.0