-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use node-option with ts-node #5047
Comments
It seems the issue could be located in mocha.js lines 84-86, where the presence of node-option drops the already parsed node args (in nodeArgs variable) instead of combining them |
Curiosity: why provide both The list of steps provided seems reasonable, but I'm not getting the exact same output locally. Could you please post an isolated reproduction that a maintainer can run with only 1-2 commands, such as a GitHub repository, GitHub Gist, or Stackbliz container? |
you need ts-node/register to compile ts on the fly Here is an example |
Got it, thanks! Makes sense. +1 to your (very helpful, thanks!) comment that Mocha is overriding the implicit-ish
...where "happily" ignores the loader notice. That's discussed in #5002. I think we can consider this a docs issue similar to #5002 that it's not clear how to use Node import/loader/require options together. Filed #5087 to track adding docs. It links to mochajs/mocha-examples#76 as a start. Aside: in general, it's not great practice to upload a Thanks for filing! |
Prerequisites
faq
labelnode_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
when running mocha with both ts-node and node-option parameters, ts-node file extensions (.ts) are no longer supported
Steps to Reproduce
node node_modules/mocha/bin/mocha.js --no-warnings --loader=ts-node/esm --require ts-node/register --ui bdd --node-option experimental-wasm-gc src/test.spec.ts
Expected behavior:
I expect the test to run
Actual behavior:
When running the above, I get a TypeError: Unknown file extension ".ts"
If I remove
--node-option experimental-wasm-gc
I don't get the errorIf I run
node --experimental-wasm-gc node_modules/mocha/bin/mocha.js --no-warnings --loader=ts-node/esm --require ts-node/register --ui bdd src/test.spec.ts
, then the test complains that the experimental-wasm-gc option is missing (I'm loading a WebAssembly)Reproduces how often:
Always
Versions
mocha --version
:10.1.0
node_modules/.bin/mocha --version
:10.1.0
node --version
:v21.3.0
ts-loader": "^9.4.1
"ts-node": "^10.9.1",
tsc Version 4.9.5
Additional Information
The text was updated successfully, but these errors were encountered: