feat: add codeceptjs/assertions subpath and hopeThat.noErrors()#5526
Merged
feat: add codeceptjs/assertions subpath and hopeThat.noErrors()#5526
Conversation
- Expose the built-in assertion factories (equals, includes, empty,
truth) at a new `codeceptjs/assertions` subpath so users can write
the same CodeceptJS-style assertions from scenarios and custom
helpers, without depending on chai/jest/node:assert.
- Add `hopeThat.noErrors()` that aggregates soft-assertion failures
collected during the current test and fails the scenario with a
single `empty('soft assertions')` assertion if any were recorded.
Failures reset on `event.test.before` so they do not leak across
tests. The existing `conditionalError` notes on `test.notes` are
preserved for reporters.
- New docs/assertions.md covering built-in see/dontSee, ExpectHelper,
codeceptjs/assertions, external libraries, reusable custom helpers,
WebElement-based assertions, soft assertions (hopeThat +
hopeThat.noErrors), and secret masking.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codeceptjs/assertionssubpath exports the built-in assertion factories (equals,includes,empty,truth) so they can be used directly from scenarios and custom helpers — no chai/jest/node:assert needed to get CodeceptJS-style failure messages.hopeThat.noErrors()oncodeceptjs/effects. Call it once at the end of a scenario to fail the test if anyhopeThat(...)soft assertion failed. Failures are collected into a module-level array that resets onevent.test.before, andnoErrors()throws a singleempty('soft assertions')assertion with an array diff instead of a rawError. ExistingconditionalErrornotes ontest.notesare preserved for reporters.docs/assertions.mdpage covering built-insee/dontSee, ExpectHelper, the newcodeceptjs/assertionsAPI, external libraries, reusable custom helpers, WebElement-based assertions, soft assertions (hopeThat+hopeThat.noErrors), andsecret()masking.Example
Test plan
codeceptjs/assertionssubpath resolves and each factory produces the expected failure messagehopeThat.noErrors()end-to-end againsttest/acceptance/codecept.Playwright.js:hopeThatcalls → fails with aggregatedexpected soft assertions '[...]' to be emptyand an array difftest.before)lib/effects.jsunit tests still pass (no behavior change to the happy path; only adds a push-and-forget to the failures array in the catch handler)🤖 Generated with Claude Code