-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
Hardcoded Babel config prevents code coverage for ESM TypeScript modules #614
Comments
Just to note my jest.config.cjs is:
If I do not set the 'ts-jest' config to
|
any update on this issue ? it prevents us from collecting coverage with jest |
It seems I'm facing exactly the same issue, any clue? |
Trying to migrate to ESM due to many packages from @sindresorhus requires it now, but really hard to get through these problems Also: sindresorhus/p-queue#152 |
@marceloavf @piranna for what it's worth, I've been using c8 these days for my projects that are ESM. It's not perfect, but I find it works well enough for me. |
FYI for those using jest. Using the https://jestjs.io/docs/configuration#coverageprovider-string Edit: There are some drawbacks from using |
For anybody else struggling with this, here is a gist with some patches you can apply using |
Unfortunately this patch didn't work for me (probably because I do not use babel in my project and just ts-node, resp. having anorther software version). I just fixed it be directly replacing the |
If I create an "src/index.ts" file with the following contents:
and run
jest --coverage
, I get:Unfortunately I can't rename my file to "mjs" as it would not be a TypeScript file and would fail compilation.
This seems to be caused by the
packages/istanbul-lib-instrument/src/read-coverage.js
lines:Because the "sourceType" is hard coded as 'script', there is no way to change it to use 'module' and no way to modify the babel config otherwise.
The text was updated successfully, but these errors were encountered: