-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Prerequisites
node ../../node_modules/mocha/bin/mocha -r ts-node/register --loader=ts-node/esm
- [x ] Checked that your issue hasn't already been filed by cross-referencing issues with the
faqlabel - [x ] 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.
- [x ] '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
- [x ] Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node_modules/.bin/mocha --version(Local) andmocha --version(Global). We recommend that you not install Mocha globally.
Description
At first, I was getting this error Debug Failure. False expression: Non-string value passed to ts.resolveTypeReferenceDirective, likely by a wrapping package working with an outdated 'resolveTypeReferenceDirectives' signature. This is probably not a problem in TS itself.
Upgraded ts-node to latest version and then got this error ``TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts".
Added the --loader=ts-node/esm flag and now I'm getting this error ReferenceError: exports is not defined in ES module scope
Played around with module and target in tsconfig.json and none has helped. Changing target from commonjs to es2015 gives me error saying that it Error: Cannot find module yadayada import from soandso.
I'm out of ideas.
Steps to Reproduce
- Install Typescript 4.5.4, ts-node 10.8.2, mocha 10.0.0, run tests written in typescript with the npm command above.
Expected behavior: Should run tests
Actual behavior: Tests not running due to error mentioned above.
Reproduces how often: 100%
Versions
typescript 4.5.4
ts-node 10.8.2
mocha 10.0.0
Windows 10 64-bit
- The output of
mocha --versionandnode_modules/.bin/mocha --version: - The output of
node --version: - Your operating system
- name and version:
- architecture (32 or 64-bit):
- Your shell (e.g., bash, zsh, PowerShell, cmd):
- Your browser and version (if running browser tests):
- Any third-party Mocha-related modules (and their versions):
- Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version):