mocha
mocha copied to clipboard
TypeScript with `moduleResolution=nodenext` hits `error TS5110`
Bug Report Checklist
- [X] I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- [X] I have searched for related issues and issues with the
faqlabel, but none matched my issue. - [X] I have '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, my usage of Mocha, or Mocha itself.
- [ ] I want to provide a PR to resolve this
Expected
Successfully run mocha tests for my typescript project
Actual
W.r.t https://github.com/mochajs/mocha-examples/tree/main/packages/typescript I tried env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' and hit the following error:
$ n run ts_test
> [email protected] ts_test
> export NODE_ENV=development && env TS_NODE_COMPILER_OPTIONS='{"module": "commonjs" }' ./node_modules/.bin/nyc --timeout 10000 --recursive --check-leaks --reporter=lcov --reporter=text --reporter=text-summary --reporter=html ./node_modules/.bin/mocha -r ts-node/register tests/**/*.ts --reporter mocha-junit-reporter --reporter-options mochaFile=test_reports/mocha/test-results.xml --exit
(node:150779) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:150779) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Exception during run: error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'.
No test is run at all.
Minimal, Reproducible Example
Not minimal but here you go: https://github.com/khteh/Node.JSRestAPI
Versions
Mocha: 10.6.0 Node: 22.2.0
Additional Info
https://github.com/mochajs/mocha/issues/5156