Chai

BDD/TDD assertion library for Node.js and the browser, framework-agnostic

Library
npm
v6.3.0
8,265 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
85 /100 Excellent
Development Activity 88
Maintenance 80
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
77 /100 Good
Architecture 80
Code Quality 82
Innovation 68
Learning Curve 78

Chai is an assertion library that plugs into any JavaScript test framework (Mocha, Jest, Vitest, and others) to provide readable, chainable assertions. Rather than locking you into one syntax, it ships three interchangeable styles — assert (classic TDD-style calls), expect, and should (both BDD-style chains) — so teams can pick whichever reads most naturally for their codebase.

Beyond the built-in assertions, Chai’s plugin architecture lets the community extend it with domain-specific matchers (chai-as-promised, sinon-chai, chai-http, and dozens more), which combined with its long track record and huge install base has made it a default assertion layer across the Node.js testing ecosystem.

What You Get

  • Three assertion styles — assert, expect, should — importable individually or registered globally via chai/register-*
  • A large built-in assertion vocabulary covering equality, type checks, object shape, array/collection membership, and more
  • A documented plugin API for building custom matchers, with an ecosystem of existing plugins (chai-as-promised, sinon-chai, chai-http)
  • Framework-agnostic design that works the same whether paired with Mocha, Jest, Vitest, or any other test runner
  • Both Node.js and browser support from the same package, usable directly via a <script type="module"> tag
  • A stable, decade-plus track record as one of the most widely depended-on assertion libraries in the npm ecosystem

Common Use Cases

  • Writing expressive test assertions (expect(value).to.equal(x)) in a Mocha, Jest, or Vitest test suite
  • Migrating a codebase between assertion styles (assert → expect → should) without changing test runners
  • Extending assertions with a domain-specific plugin, such as asserting on HTTP responses (chai-http) or promise resolution (chai-as-promised)
  • Sharing one assertion library across a monorepo’s Node.js backend tests and browser-run frontend tests

Under The Hood

Architecture - Chai’s lib/chai directory implements the three assertion styles (assert.js, interface/expect.js, interface/should.js) as thin adapters over a shared Assertion core (lib/chai/assertion.js) that holds the actual comparison logic and chainable-method registration (lib/chai/utils), so all three styles share one underlying implementation and stay behaviorally consistent. A separate plugin registration system (use()) lets third-party packages extend the Assertion prototype and the interfaces without modifying chai’s core, which is what enables the large external plugin ecosystem.

Tech Stack - Chai is published as a pure ESM package ("type": "module") with no required runtime dependencies for its core assertions (deep-equality and inspection are delegated to small companion packages from the chaijs org: deep-eql, loupe, check-error, pathval), keeping the dependency footprint minimal for a library this widely installed. Tests run via its own suite in test/ covering each interface style plus plugin registration and configuration behavior, executed with web-test-runner for browser-environment coverage alongside Node.js testing.

Code Quality - The separation between assertion styles and the shared Assertion core keeps the three interfaces from drifting out of sync, and companion packages (deep-eql, loupe) are maintained as focused single-purpose modules rather than being reimplemented inline. Test coverage is broad, spanning assert.js, expect.js, should.js, configuration.js, and plugins.js as separate suites, reflecting the maturity expected of a decade-old, extremely widely-used testing dependency. History.md and ReleaseNotes.md document a long, actively maintained release history rather than sporadic version bumps.

API Design - The three interchangeable styles (assert.equal(a, b), expect(a).to.equal(b), a.should.equal(b)) are chai’s signature ergonomic choice, letting teams pick the phrasing that reads best for their codebase without giving up any assertion coverage. The BDD styles (expect/should) use natural-language chaining (.to.be.an('array').that.includes(x)) that reads close to plain English, which is a major reason chai remains a common pairing with Mocha even though most modern test runners now ship their own basic assertions.

Used by 27 apps in this directory

JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,266

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
84
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 1 months ago
TypeScript
91%
AGPL 3.0

PeerTube

Social Media

15,362

A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.

View details
96
Repo Health
75
Technical
66
Dependency
Built with
TypeScript 91%
Updated 1 weeks ago
TypeScript
64%
AGPL 3.0

Puter

Developer Tools · File Storage

43,864

A self-hostable, web-based internet OS with desktop GUI, cloud storage, AI drivers, and a developer SDK — all running in your browser.

View details
88
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 64%
JavaScript 33%
Updated 5 days ago
TypeScript
97%
Other

Rocket.Chat

Team Chat

46,304

The secure, self-hosted team communications platform for organizations that cannot compromise on data sovereignty.

View details
96
Repo Health
79
Technical
63
Dependency
Built with
TypeScript 97%
Updated 5 days ago
TypeScript
83%
AGPL 3.0

Standard Notes

Note Taking

6,681

End-to-end encrypted notes and files — private by design, built to last, and fully self-hostable.

View details
89
Repo Health
83
Technical
68
Dependency
Built with
TypeScript 83%
JavaScript 14%
Updated 6 days ago
TypeScript
91%
MIT

Super Productivity

Productivity · Project Management

23,103

A privacy-respecting, local-first task manager with built-in timeboxing, Pomodoro timer, and deep integrations for Jira, GitHub, GitLab, and CalDAV — no accounts, no data collection, ever.

View details
91
Repo Health
81
Technical
69
Dependency
Built with
TypeScript 91%
Updated 5 days ago
Rust
93%
Other

Tabby

AI Code Assistants

33,924

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
55
Repo Health
78
Technical
61
Dependency
Built with
Rust 93%
Updated 4 months ago
HTML
68%
AGPL 3.0

ToolJet

AI Agents · Low Code Platforms · No Code Platforms

41,123

Open-source AI-native platform to build and deploy internal tools, workflows, and AI agents with a visual drag-and-drop builder and 80+ data source integrations.

View details
94
Repo Health
81
Technical
63
Dependency
Built with
HTML 68%
JavaScript 20%
Updated 5 days ago
TypeScript
95%
Apache 2.0

Void

AI Code Assistants · Automation · Code Editors

28,733

Open-source AI code editor with direct LLM integration and data privacy

View details
44
Repo Health
84
Technical
68
Dependency
Built with
TypeScript 95%
Updated 4 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers