Skip to content

fix assert.rejects usage in tests#194

Merged
webketje merged 1 commit intometalsmith:masterfrom
pirxpilot:fix-test
Mar 8, 2026
Merged

fix assert.rejects usage in tests#194
webketje merged 1 commit intometalsmith:masterfrom
pirxpilot:fix-test

Conversation

@pirxpilot
Copy link
Contributor

assert.rejects needs to be awaited inside of the async test body.
If it is not, the test is effectively ignored since any exceptions are thrown after the test function completes.

other changes:

  • transform option is required by the plugin
  • wrapping a Promise returned by Metalsmith invocation is not necessary: assert.rejects takes a Promise as first argument

see:
https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message

`assert.rejects` needs to be awaited inside of the async test body
if it is not the test is effectively ignored since any exceptions are
thrown after the test function completes

other changes:
- `transform` option is required by plugin
- wrapping a Promise returned by `Metalsmith` invocation is not
  necessary: `assert.rejects` takes a Promise as first argument

see:
https://nodejs.org/api/assert.html#assertrejectsasyncfn-error-message
@webketje webketje merged commit 03d9ce9 into metalsmith:master Mar 8, 2026
5 checks passed
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