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 testdouble loader with mocha and typescript #487
Comments
Ah, just found https://github.com/cspotcode/multiloader which seems to be working. I'm now invoking mocha like so:
It seems that the multiloader is working because there are two warnings regarding the experimental loader. However, I'm still seeing that
I'm trying to make a testdouble for the
Note that I call
Am I doing something wrong here? Why isn't |
Turns out swapping the order of loaders solves the problem! This command causes all my tests to run as expected: |
Description
I'm trying to use
td.replaceEsm
which requires thetestdouble
loader but I also need to use thets-node/esm
loader and can't figure out how to use both simulatenously.Issue
I have a nodejs application that I'm slowly migrating to typescript. I'm using
mocha
as my testing framework. I've found I need to pass-n loader=ts-node/esm
to mocha so that it doesn't complain about my typescript test files. Without that loader I get the following error:If I execute mocha like so, the above error goes away and all my tests run successfully:
npx mocha -n loader=ts-node/esm src/**/*.test.ts
However, now that I need to use
td.replaceEsm
with thetestdouble
loader, I get similar errors above (note the two loaders I pass in the mocha command:I've also tried swapping the order of loaders but that causes the
td.replaceEsm
in one of my tests to fail (assuming I've set that up correctly):Is there a mechanism to use both the testdouble and ts-node loader?
Environment
node -v
output: v17.6.0npm -v
(oryarn --version
) output: 7.6.0npm ls testdouble
(oryarn list testdouble
) version: nodejs-server@ /Users/paymahn/code/tripvector/tripvector-mono/backend└── testdouble@3.16.5
The text was updated successfully, but these errors were encountered: