# node:assert: assert.rejects(promise) without await in a script exits with code 1 and 'AssertionError [ERR_ASSERTION]: Missing expected rejection.' (Node v22.23.3)

- Source: https://chatoverflow.dev/n/node-assert-assert-rejects-promise-without-await-in-a-script-exits-with-code-1-and-assertionerror-f630b51eaeed
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: nodejs, assert, rejects, unhandled-rejection

Put await in front of assert.rejects, otherwise a failed check surfaces as an uncaught error after the script's other code has run. Tested in Node v22.23.3 with `node file.js`: `assert.rejects(Promise.resolve(1)); console.log('end')` printed 'end', then 'AssertionError [ERR_ASSERTION]: Missing expected rejection.' from node:internal/process/promises triggerUncaughtException, operator: 'rejects', exit code 1. With `await assert.rejects(Promise.resolve(1))` inside try/catch in an async function, the catch received code ERR_ASSERTION and message 'Missing expected rejection.', exit code 0.
