Skip to content

Handle AssertionError as failure, not error#150

Merged
LeaVerou merged 1 commit into
mainfrom
handle-assertion-error
May 24, 2026
Merged

Handle AssertionError as failure, not error#150
LeaVerou merged 1 commit into
mainfrom
handle-assertion-error

Conversation

@DmitrySharabin
Copy link
Copy Markdown
Member

@DmitrySharabin DmitrySharabin commented May 22, 2026

Summary

  • Treat assertion errors (Node assert, Chai, etc.) as test failures with proper diffs instead of raw error dumps
  • Duck-type via "actual" in e to support multiple assertion libraries
  • Extract both actual and expected from the error for diff output
  • Always fail when an assertion throws, regardless of hTest's own check() result

Closes #114

Test plan

  • New test in tests/errors.js verifies actual and expected are extracted from the assertion error and the test fails
  • Full suite passes (88/88)

🤖 Generated with Claude Code

@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2026

Deploy Preview for h-test ready!

Name Link
🔨 Latest commit c4e1a2a
🔍 Latest deploy log https://app.netlify.com/projects/h-test/deploys/6a12d8ebd893860008632e5f
😎 Deploy Preview https://deploy-preview-150--h-test.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@DmitrySharabin DmitrySharabin force-pushed the handle-assertion-error branch 2 times, most recently from 609dd1b to 2274d7b Compare May 22, 2026 19:57
@DmitrySharabin DmitrySharabin changed the title Handle AssertionError as failure, not error Handle AssertionError as failure, not error, closes #114 May 22, 2026
@DmitrySharabin DmitrySharabin changed the title Handle AssertionError as failure, not error, closes #114 Handle AssertionError as failure, not error May 22, 2026
@DmitrySharabin DmitrySharabin force-pushed the handle-assertion-error branch 4 times, most recently from 86da6fa to f62d3e1 Compare May 22, 2026 20:41
Duck-type errors with an `actual` property (Node assert, Chai, etc.)
and extract the value for normal diff output instead of dumping a
raw error + stack trace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@DmitrySharabin DmitrySharabin force-pushed the handle-assertion-error branch from f62d3e1 to c4e1a2a Compare May 24, 2026 10:54
@LeaVerou LeaVerou merged commit 1b10540 into main May 24, 2026
4 checks passed
@LeaVerou LeaVerou deleted the handle-assertion-error branch May 24, 2026 15:39
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.

Handle AssertionError as a failure, not an error, for compat with other libraries

2 participants