Skip to content

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Jan 25, 2026

Add assert.ifError() and expect().to.ifError() assertions for Node.js-style callback error checking. Passes for falsy values, throws Error instances, and fails for truthy non-Error values.

Includes comprehensive tests (35 cases), chai shim integration, and full documentation updates.

Add assert.ifError() and expect().to.ifError() assertions for
Node.js-style callback error checking. Passes for falsy values,
throws Error instances, and fails for truthy non-Error values.

Includes comprehensive tests (35 cases), chai shim integration, and full documentation updates.
@nev21 nev21 added this to the 0.1.5 milestone Jan 25, 2026
Copilot AI review requested due to automatic review settings January 25, 2026 05:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds the ifError() assertion for Node.js-style callback error handling. The implementation follows Node.js's assert.ifError() behavior: it passes for falsy values, throws Error instances directly, and fails with an AssertionFailure for truthy non-Error values.

Changes:

  • Added ifError() assertion to both assert and expect APIs
  • Integrated Chai.js compatibility shim support for ifError()
  • Added comprehensive test coverage with 35 test cases covering falsy values, Error instances, truthy non-Error values, custom messages, edge cases, and typical use patterns

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/src/assert/funcs/ifError.ts Core implementation of ifError assertion function
core/src/assert/assertClass.ts Integration of ifError into assert class
core/src/assert/interface/IAssertClass.ts TypeScript interface definition for assert.ifError()
core/src/assert/interface/ops/IToOp.ts TypeScript interface definition for expect().to.ifError()
core/src/assert/ops/toOp.ts Integration of ifError into expect chain
core/test/src/assert/assert.ifError.test.ts Comprehensive test suite with 35 test cases
shim/chai/src/assert/chaiAssert.ts Chai compatibility shim integration
shim/chai/test/src/chaiAssert.test.ts Chai compatibility test
core/README.md Documentation update listing ifError in features
shim/chai/README.md Documentation update listing ifError in implemented features
core/src/assert/funcs/keysFunc.ts Whitespace cleanup (removing trailing spaces from comments)
core/src/assert/ops/keysOp.ts Whitespace cleanup (removing trailing spaces from comments)

@nev21 nev21 enabled auto-merge (squash) January 25, 2026 05:41
@nev21 nev21 merged commit b1c0f06 into main Jan 25, 2026
16 checks passed
@nev21 nev21 deleted the nev21/ifError branch January 25, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants