If one among multiple ESM tests has a syntax error, then Mocha doesn’t report which one #4551
Closed
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faq
label - Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
- 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
If I run multiple ESM tests (e.g. via npm t test*.mjs
), and one of them has a syntax error, then Mocha doesn’t tell me which file it is.
Steps to Reproduce
Repository with MCVE: https://github.com/rauschma/mocha-test-repo
Execute either of the following two commands:
npm t test*.mjs
npm t 'test*.mjs'
test2.mjs
has a syntax error.
Expected behavior: I’d like Mocha to tell me which file has the syntax error.
Actual behavior: I’m getting the following error message.
SyntaxError: Unexpected token '=>'
at Loader.moduleStrategy (internal/modules/esm/translators.js:117:18)
at async link (internal/modules/esm/module_job.js:42:21)
Reproduces how often: 100%
Versions
- The output of
mocha --version
andnode node_modules/.bin/mocha --version
: 8.2.1 (there is no globally installed Mocha) - The output of
node --version
: v14.15.4
Activity