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.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
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
- Three assertion styles:
expect,shouldandassert. - Readable chains: Natural-language assertions with clear failure messages.
- Plugins: Extend with chai-as-promised, sinon-chai, chai-http and others.
- Framework-agnostic: Works with Mocha, node:test, Jasmine and more.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 10 November 2026.
- Community: About 8,300 GitHub stars.
Cons
- ESM-only in recent versions: Older CommonJS projects may need to stay on earlier majors.
- Unneeded with Jest/Vitest: Those include their own
expect.
Usage and Links (Example)
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.
Recommended for?
- Mocha users needing an assertion library.
- 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.
MMochaMocha is a long-running, MIT-licensed JavaScript test framework for Node.js and browsers, with BDD and TDD interfaces, async support, hooks, parallel mode and a large reporter ecosystem.Compare with Chai
JJasmineJasmine is a long-established, MIT-licensed behaviour-driven JavaScript testing framework for browsers and Node.js, with built-in assertions, spies and asynchronous support and no required dependencies.Compare with Chai
SSinon.JSSinon.JS is a BSD-3-Clause library of standalone test spies, stubs and mocks for JavaScript, plus fake timers and fake XHR/servers, and works with any test framework.Compare with Chai
JJestJest is a free, open-source JavaScript test runner with zero-config defaults, mocks, and snapshot testing.Compare with Chai
VVitestVitest is a free, open-source unit test runner that reuses a Vite project's config, transforms, and plugins.Compare with Chai
NNode.js Test Runner (node:test)The Node.js test runner is the built-in `node:test` module, stable since Node.js 20, providing describe/it tests, mocking, snapshots, coverage and reporters with no extra dependencies.Compare with Chai