CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

chaijs/chai

Scanned commit d86de2a951 dated 2026-09-29 — last upstream commit. Generated by codevetter 1.15.0 on 2026-10-02.

github.com/chaijs/chai ↗ · 75 files · 848 KB

chai Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.

Deep analysis by cli:codex via the codex CLI on 2026-10-02 (358s) — every claim below links to its cited source files. Source inspection; upstream code and tests were not executed.

Overview

Chai is an ECMAScript-module assertion library for JavaScript tests in Node.js and browsers, offering expect, should, and assert interfaces over a shared assertion engine. Its distinctive implementation combines flag-carrying fluent chains, configurable failure diagnostics, proxy-based typo detection, and plugins that extend or overwrite assertions. At commit d86de2a9519bdd0d89aa64c9fbcc0e880513b153, the published entrypoint is an esbuild-generated bundle; this brief reflects bounded source inspection, with no repository code or tests executed.

System map

The runtime consists of a shared Assertion class, built-in registrations, three public interfaces, and utility functions. Module evaluation installs the core assertions, while consumers explicitly activate plugins or the should prototype accessor. State is held in assertion objects and module-level configuration and registries. Distribution is a generated ESM bundle with separate global-registration modules.

Feature catalog

Users choose fluent expect or should assertions, or named assert helpers. Built-ins cover scalar values, object structure, collections, numeric relationships, exceptions, predicates, and callback-driven changes. Modifiers alter comparison depth, property lookup, collection ordering, inclusion, and negation. Failure formatting and plugin installation are additional public capabilities.

Data flow

Assertion input becomes a target reference plus metadata stored in flags. Chain getters and methods propagate those flags, while selected operations replace the target for subsequent assertions. Comparison results pass through a common negation and error-construction boundary. Outputs are continuing assertion objects, explicit return values, or thrown errors; inspected callback operations can also modify consumer-owned state.

Behavior traces

The inspected flows cover module initialization, ordinary and deep equality, property chaining, exception checks, callback changes, and plugin installation. All assertion traces describe source execution order rather than observed runs. The closest equivalent to a persistence flow is propagation of chain state and mutation of consumer-owned objects; these paths do not implement durable storage.

Testing signals

Tests and CI were inspected, not executed; no passing result or measured coverage is asserted. The configured suites use Mocha for Node and Web Test Runner with Playwright for browsers. Inspected tests exercise interface behavior, error diagnostics, plugin installation, utility registration, configuration, subsets, and cross-realm exceptions. File-selection rules leave some tracked nested tests outside the default suites, and the inventory is bounded rather than exhaustive.

Risk map

The principal observed boundaries are execution of consumer callbacks and getters, shared prototype/configuration mutation, and assertion-error disclosure. Plugins operate with the consumer process's capabilities. Source inspection also identifies recursive subset matching and exception-sensitive flag restoration as areas for targeted investigation. These are observations or explicitly labeled hypotheses, not confirmed vulnerabilities or runtime failures.

Extension points

Extensions enter through use and Assertion's registration helpers rather than a router or service registry. New behavior can be implemented as properties, methods, or callable chain properties, with corresponding overwrite mechanisms. Flags carry custom state and registration events expose extension activity. Configuration supplies additional hooks for comparison and diagnostics.

Contributor handoff

Begin with the shared engine and the exact public interface involved in the task. Preserve chain continuation, modifier state, target changes, stack filtering, aliases, and diagnostic metadata when editing assertions. Tests and CI were inspected, not executed, so future validation must produce fresh results under explicit execution authorization. The inspected inventory is bounded, and older contribution examples should be reconciled with current scripts.

Languages

LanguageFilesShare of source
JavaScript5698%
Markdown5docs/config
JSON4docs/config
YAML4docs/config
TypeScript12%

Start reading here

Probable source entrypoint: lib/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

lib/ (33 files)

Source layout — lib/

PathFiles
lib/chai/32
lib/chai.js1

Repository structure

Top-level pathFiles
lib/33
test/20
.github/5

Docs found: CONTRIBUTING.mdREADME.md

Package

package.json — chai v0.0.0-development, 18 declared dependencies.

@eslint/js@rollup/plugin-commonjs@web/dev-server-rollup@web/test-runner@web/test-runner-playwrightassertion-errorc8check-errordeep-eqlesbuildeslinteslint-plugin-jsdoc

CI & config entrypoints

Structural health signals

Average score 8.6/10 across 57 analyzed source files; 6 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history