You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or a nice-to-have?? Please describe.
I can successfully run my tests on CLI by running mocha --loader=ts-node/esm. However, I need to be able to do this algorithmically, not via CLI, and there doesn't appear to be any way to do so.
Because of this, when I run await mocha.loadFilesAsync();, I get an exception: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
Describe the solution you'd like
constmocha=newMocha({loader: "ts-node/esm"});
Describe alternatives you've considered
I've tried adding loader to mocha.opts and package.json and .mocharc.json and it doesn't seem to pick any of these up when run programmatically.
The text was updated successfully, but these errors were encountered:
The loader option is a feature of Node itself, not Mocha, and is passed directly through to the Node binary via this file: https://github.com/mochajs/mocha/blob/master/bin/mocha.js. There's no way to provide --loader from within an existing Node process.
Yup, the module.register API is the way to do this!
mochajs/mocha-examples#75 -> mochajs/mocha-examples#76 has examples showing very straightforward on-the-fly transpilation: one with ts-node, the other with tsx. If you're looking for a more algorithmic/fancy example than that then I'd suggest posting an issue over on that repo.
Is your feature request related to a problem or a nice-to-have?? Please describe.
I can successfully run my tests on CLI by running
mocha --loader=ts-node/esm
. However, I need to be able to do this algorithmically, not via CLI, and there doesn't appear to be any way to do so.Because of this, when I run
await mocha.loadFilesAsync();
, I get an exception:TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"
Describe the solution you'd like
Describe alternatives you've considered
I've tried adding loader to
mocha.opts
andpackage.json
and.mocharc.json
and it doesn't seem to pick any of these up when run programmatically.The text was updated successfully, but these errors were encountered: