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-chai

v0.1.2

Published

Migrate Chai assertions to bupkis

Readme

@bupkis/from-chai

Migrate Chai assertions to bupkis with a single command.

Supports both BDD style (expect/should) and TDD style (assert) assertions.

Installation

npx @bupkis/from-chai

Or install locally:

npm install -D @bupkis/from-chai

Usage

CLI

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

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

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

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

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

Programmatic API

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

// Transform a code string
const { code, transformCount, warnings } = await transformCode(`
  import { expect } from 'chai';
  expect(foo).to.equal(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

BDD Style (expect)

| Chai | bupkis | | --------------------------------- | ------------------------------------------------ | | expect(x).to.equal(y) | expect(x, 'to be', y) | | expect(x).to.deep.equal(y) | expect(x, 'to deep equal', y) | | expect(x).to.be.true | expect(x, 'to be true') | | expect(x).to.be.false | expect(x, 'to be false') | | expect(x).to.be.null | expect(x, 'to be null') | | expect(x).to.be.undefined | expect(x, 'to be undefined') | | expect(x).to.be.ok | expect(x, 'to be truthy') | | expect(x).to.exist | expect(x, 'to be defined') | | expect(x).to.be.a('string') | expect(x, 'to be a', 'string') | | expect(x).to.be.instanceof(Y) | expect(x, 'to be an instance of', Y) | | expect(x).to.have.property('y') | expect(x, 'to have property', 'y') | | expect(x).to.have.length(3) | expect(x, 'to have length', 3) | | expect(x).to.contain(y) | expect(x, 'to contain', y) | | expect(x).to.match(/foo/) | expect(x, 'to match', /foo/) | | expect(x).to.be.above(5) | expect(x, 'to be greater than', 5) | | expect(x).to.be.below(10) | expect(x, 'to be less than', 10) | | expect(x).to.be.at.least(5) | expect(x, 'to be greater than or equal to', 5) | | expect(x).to.be.at.most(10) | expect(x, 'to be less than or equal to', 10) | | expect(fn).to.throw() | expect(fn, 'to throw') | | expect(fn).to.throw(Error) | expect(fn, 'to throw', Error) | | expect(x).to.be.empty | expect(x, 'to be empty') |

Negation is supported:

| Chai | bupkis | | --------------------------- | --------------------------- | | expect(x).to.not.equal(y) | expect(x, 'not to be', y) | | expect(x).not.to.equal(y) | expect(x, 'not to be', y) |

TDD Style (assert)

| Chai | bupkis | | ---------------------------- | -------------------------------------- | | assert.equal(x, y) | expect(x, 'to be', y) | | assert.strictEqual(x, y) | expect(x, 'to be', y) | | assert.deepEqual(x, y) | expect(x, 'to deep equal', y) | | assert.isTrue(x) | expect(x, 'to be true') | | assert.isFalse(x) | expect(x, 'to be false') | | assert.isNull(x) | expect(x, 'to be null') | | assert.isUndefined(x) | expect(x, 'to be undefined') | | assert.isOk(x) | expect(x, 'to be truthy') | | assert.isArray(x) | expect(x, 'to be a', 'array') | | assert.isString(x) | expect(x, 'to be a', 'string') | | assert.typeOf(x, 'string') | expect(x, 'to be a', 'string') | | assert.instanceOf(x, Y) | expect(x, 'to be an instance of', Y) | | assert.property(x, 'y') | expect(x, 'to have property', 'y') | | assert.lengthOf(x, 3) | expect(x, 'to have length', 3) | | assert.include(x, y) | expect(x, 'to contain', y) | | assert.match(x, /foo/) | expect(x, 'to match', /foo/) | | assert.isAbove(x, 5) | expect(x, 'to be greater than', 5) | | assert.isBelow(x, 10) | expect(x, 'to be less than', 10) | | assert.throws(fn) | expect(fn, 'to throw') | | assert.isEmpty(x) | expect(x, 'to be empty') |

Negated assertions (assert.notEqual, assert.isNotTrue, etc.) are also supported.

Chai Plugins

The following plugins are supported:

chai-as-promised:

| Chai | bupkis | | ---------------------------------- | -------------------------------------- | | expect(p).to.eventually.equal(y) | expect(p, 'to be fulfilled with', y) | | expect(p).to.be.fulfilled | expect(p, 'to be fulfilled') | | expect(p).to.be.rejected | expect(p, 'to be rejected') | | expect(p).to.be.rejectedWith(E) | expect(p, 'to be rejected with', E) |

chai-string:

| Chai | bupkis | | ----------------------------- | --------------------------------- | | expect(s).to.startWith('x') | expect(s, 'to start with', 'x') | | expect(s).to.endWith('x') | expect(s, 'to end with', 'x') |

chai-subset:

| Chai | bupkis | | ------------------------------- | ---------------------------- | | expect(x).to.containSubset(y) | expect(x, 'to satisfy', y) |

Plugin imports and chai.use() calls are automatically removed.

Import Handling

The transformer automatically:

  • Replaces import { expect } from 'chai' with import { expect } from 'bupkis'
  • Removes import { assert } from 'chai' (TDD assertions become expect() calls)
  • Removes all chai-* plugin imports
  • Removes all chai.use() calls
  • Warns about unrecognized plugins passed to chai.use()

Options

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

Handling Unsupported Assertions

In best-effort mode (default), unsupported assertions are preserved with a TODO comment:

// TODO: Manual migration needed - unsupported matcher 'someObscureMatcher'
expect(x).to.someObscureMatcher(y);

Search for "TODO: Manual migration needed" in your codebase after running the transform to find items requiring manual review.

License

Blue Oak Model License 1.0.0