-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Error on ESM TypeScript project when using ts-node + mocha #1094
Comments
Hello, I did not forget about this, just being busy with the family, and decided not to spend time on ts-auto-mock. Anyway, it has been 2 months 🤣 I couldn't fix the problem or find the root cause yet but I've checkout out your repo and I've realised that it was not configured correctly, or at least the transformer was not running at all. Instead of using the example provided by ts-auto-mock I've installed ts-patch to run the transformer. this unfortunately gave me another error
I think I am almost there, I just need to study esm modules. I am quite certain that the error is because of something we do in ts-auto-mock about imports that does not get converted correctly for esm |
I just hit this. It's because the transformer generates a namespaced import, when actually a default import is needed. Changing to this generates correctly: core.ts.factory.createImportClause(false, moduleName) Though obv that would need to be conditional. |
Error is thrown when running mocha tests
ESM TypeScript project is being tested with Mocha, when
ts-auto-mock
'screateMock
is called an error is thrownYour environment
Steps to reproduce
Example repo here: https://github.com/lostvicking/esm-ts-auto-mock-example
Run
npm test
Expected behavior
Expect
createMock
to generate a mock of specified type without errors.Actual behavior
An error is thrown:
The text was updated successfully, but these errors were encountered: