Bug Report Checklist
Expected
ESM errors thrown at top level gets silently swallowed (hidden) and does not fail the suite (as I assume is expected). Mocha ignores the error and keeps going. Makes it really annoying to debug whats wrong. Any it tests defined before the error do get "registered" normally though.
Actual
Nothing, simply ignores the error and keeps going
Minimal, Reproducible Example
given a test test/add.test.ts suite like this
import assert from 'node:assert/strict'
throw new Error()
it('should add stuff', () => {
const b = 1 + 1;
assert.equal(2, b)
})
Then mocha --extension ts will simply output
(node:64751) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
0 passing (0ms)
instead of exposing the error.
Versions
Mocha 11.7.1
Node v24.3.0
Additional Info
Conversely if you change it to
import assert from 'node:assert/strict'
it('should add stuff', () => {
const b = 1 + 1;
assert.equal(2, b)
})
throw new Error()
it will then output
Running main test suite...
(node:64877) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✔ should add stuff
1 passing (1ms)
Still no mention of the error.
Bug Report Checklist
faqlabel, but none matched my issue.Expected
ESM errors thrown at top level gets silently swallowed (hidden) and does not fail the suite (as I assume is expected). Mocha ignores the error and keeps going. Makes it really annoying to debug whats wrong. Any
ittests defined before the error do get "registered" normally though.Actual
Nothing, simply ignores the error and keeps going
Minimal, Reproducible Example
given a test
test/add.test.tssuite like thisThen
mocha --extension tswill simply outputinstead of exposing the error.
Versions
Mocha 11.7.1
Node v24.3.0
Additional Info
Conversely if you change it to
it will then output
Still no mention of the error.