CheckOps home

Tools directory

C

CheckOps

Chai

Chai is an MIT-licensed BDD/TDD assertion library for Node.js and browsers, offering expect, should and assert styles and a large plugin ecosystem, pairing with any test framework.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

Chai is an assertion library for Node.js and the browser that can be paired with any JavaScript testing framework. It is best known as Mocha’s companion, because Mocha deliberately ships without assertions. Chai offers three styles: expect and should for readable BDD chains (expect(total).to.equal(12), user.should.have.property('id')) and assert for classic TDD-style calls.

Chai’s chainable language includes deep equality, property and length checks, type checks, include, members, throw, closeTo and more. A rich plugin ecosystem adds domain matchers, such as chai-as-promised for promises, sinon-chai for Sinon spies and chai-http for HTTP assertions. Recent major versions are ESM-only, and the latest release, v6.3.0, was published on 30 September 2026.

The source code is at chaijs/chai on GitHub under the MIT licence, with about 8,300 stars; the most recent commit was on 10 November 2026.

Chai can also be loaded directly in the browser for in-page test runners.

Features

  1. Three assertion styles: expect, should and assert.
  2. Readable chains: Natural-language assertions with clear failure messages.
  3. Plugins: Extend with chai-as-promised, sinon-chai, chai-http and others.
  4. Framework-agnostic: Works with Mocha, node:test, Jasmine and more.

Pros

  1. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 10 November 2026.
  3. Community: About 8,300 GitHub stars.

Cons

  1. ESM-only in recent versions: Older CommonJS projects may need to stay on earlier majors.
  2. Unneeded with Jest/Vitest: Those include their own expect.
npm install --save-dev chai
import { expect } from "chai";
import { createOrder } from "../src/orders.js";

describe("createOrder", () => {
  it("builds an order", () => {
    const order = createOrder([{ sku: "A", qty: 2 }]);
    expect(order).to.have.property("id").that.is.a("string");
    expect(order.items).to.have.lengthOf(1);
    expect(() => createOrder([])).to.throw("empty order");
  });
});

Resources:

Pricing

Chai is free and open source under the MIT licence.

  1. Mocha users needing an assertion library.
  2. Teams that like expressive BDD-style assertions in any runner.

Conclusion

Chai remains the classic JavaScript assertion library, readable and extensible, and the natural partner for Mocha.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with Chai side by side.