CodeVetter · Repo Unpack · Behavior traces
chaijs/chai
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.
- Startup: importing lib/chai.js evaluates its core/assertions.js dependency; that module registers language getters through Assertion.addProperty, which delegates to addProperty and defines getters on Assertion.prototype.
- Global should startup: register-should.js imports should from the bundle → calls loadShould → defines Object.prototype.should → assigns the returned helpers to globalThis.should; accessor reads unbox wrapper primitives before constructing Assertion.
- Strict equality failure: expect(actual) → Assertion → language getters → equal's methodWrapper → assertEqual's === comparison → Assertion.assert → getMessage → thrown AssertionError with actual/expected/diff metadata.
- Deep equality: .deep sets the deep flag → assertEqual locks ssfi → invokes eql → assertEql calls the comparator stored in the eql flag → common assertion evaluation; construction selected config.deepEqual or util.eql.
- Property continuation: assertProperty validates name/target and rejects nested+own → resolves path or key → checks existence/value → sets object to the property value → methodWrapper transfers that target to the next Assertion.
- Exception flow: assert.throws normalizes shorthand matchers → invokes fluent throw → assertThrows verifies a function and calls it inside try/catch → checks compatible error criteria → stores caughtErr as the target → assert.throws returns that target.
- State-change flow: change validates fn and the subject/property → reads initial → calls fn → reads final → records delta flags → asserts inequality; .by then compares the absolute before/after difference with the requested delta.
- Plugin flow: use builds an exports object → checks used.indexOf(fn) → invokes a new plugin with exports/util → records it only after successful return → returns exports for chaining; addMethod extensions subsequently dispatch registration events.