CodeVetter · Repo Unpack · Feature catalog
chaijs/chai
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.
- expect(value, message) constructs an Assertion; should()/Should() installs an Object.prototype accessor; assert(expression, message) evaluates truthiness through Assertion.assert. Registration modules expose these styles globally.
- Equality has deliberate interface differences: fluent equal/equals/eq uses === or delegates to eql when deep is set, whereas assert.equal uses == and assert.strictEqual delegates to fluent equal.
- Scalar and shape checks include a/an type matching, truthiness, strict booleans, null/undefined/NaN/existence, numeric Number-or-BigInt detection, callable checks, and extensible/sealed/frozen status.
- Object assertions support direct, own, nested, and deep property comparisons, descriptor inspection, key sets, and respondTo method checks; nested and own cannot be combined.
- Collection and text assertions provide include aliases, empty, length/lengthOf, iterable members with deep/ordered/inclusion modes, oneOf, regular-expression matching, and substring checks; deep inclusion explicitly rejects WeakSet.
- Numeric APIs include above/least/below/most aliases, within bounds, closeTo/approximately tolerance checks, finite-number checks, and assert.operator's explicit comparison-operator switch.
- Behavior assertions synchronously check thrown values against error identity/constructor/message criteria, run satisfy predicates, and measure change/increase/decrease with optional by(delta) checks.
- containSubset recursively matches object fields and array elements, compares Dates by timestamp, and accepts field validators; assert.containsSubset and doesNotContainSubset wrap it. Users can also configure diagnostics and install plugins through use.