-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specifictype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faqlabel - 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
mocha configuration contains require: ['ts-node/register'], in order to load the TS loader.
But since node_modules/ts-node/register is a folder, the new ESM loader in mocha fails to load, and throws:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '...../node_modules/ts-node/register' is not supported resolving ES modules imported from ...../node_modules/mocha/lib/esm-utils.js
Steps to Reproduce
npm i --save-dev ts-node- Add
require: ['ts-node/register']to the.mocharc.yml
Expected behavior: Should work, and at least automatically resolve some well-known loaders like ts-node.
Actual behavior: Fails miserably.
Reproduces how often: 100%
Versions
- The output of
mocha --versionandnode node_modules/.bin/mocha --version: 9.0.0 - The output of
node --version: v15.12.0 - Your operating system
- name and version: MacOS 11.12.3
- architecture (32 or 64-bit): M1
- Your shell (e.g., bash, zsh, PowerShell, cmd): bash
- Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): ts-node 9.1.1
Metadata
Metadata
Assignees
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specifictype: buga defect, confirmed by a maintainera defect, confirmed by a maintainer