Skip to content

Commit 09f5b2c

Browse files
authored
docs: explain node import swallowing error (#5401)
Fixes: [#5396](#5396)
1 parent d4168ae commit 09f5b2c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

docs-next/src/content/docs/explainers/nodejs-native-esm-support.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ More information can be found in the [Node.js documentation](https://nodejs.org/
2929
- [Watch mode](../running/cli#--watch--w) does not support ES Module test files
3030
- [Custom reporters](../reporters/third-party) and [custom interfaces](../interfaces/third-party) can only be CommonJS files
3131
- [Configuration file](../running/configuring) can only be a CommonJS file (`.mocharc.js` or `.mocharc.cjs`)
32+
- Mocha in Node.js version 24.4.0 or older [silently ignored top level errors in ESM files](https://github.com/mochajs/mocha/issues/5396).
33+
If you cannot upgrade to a newer Node.js version, you can add `--no-experimental-require-module` to the `NODE_OPTIONS` environment variable.
3234
- When using module-level mocks via libs like `proxyquire`, `rewiremock` or `rewire`, hold off on using ES modules for your test files.
3335
You can switch to using `testdouble`, which does support ESM.

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,8 @@ More information can be found in the [Node.js documentation](https://nodejs.org/
21312131
- [Custom reporters](#third-party-reporters) and [custom interfaces](#interfaces)
21322132
can only be CommonJS files
21332133
- [Configuration file](#configuring-mocha-nodejs) can only be a CommonJS file (`.mocharc.js` or `.mocharc.cjs`)
2134+
- Mocha in Node.js version 24.4.0 or older [silently ignored top level errors in ESM files](https://github.com/mochajs/mocha/issues/5396).
2135+
If you cannot upgrade to a newer Node.js version, you can add `--no-experimental-require-module` to the `NODE_OPTIONS` environment variable.
21342136
- When using module-level mocks via libs like `proxyquire`, `rewiremock` or `rewire`,
21352137
hold off on using ES modules for your test files. You can switch to using `testdouble`,
21362138
which does support ESM.

0 commit comments

Comments
 (0)