Empty coverage report when using "type": "module"
See original GitHub issueEmpty coverage report when using "type": "module"
in “package.json”.
How to configure everything to work “out of the box”?
Example repo: https://github.com/demo-source/node-app
Here is the output in the original:
Relying on the message: ExperimentalWarning: The ESM module loader is experimental.
, I assume that the source code is not converted using the module @babel/register
, and is still executed as an ESM
But if you manually change the type, but everything works. ("type": "commonjs"
)
if you add a small plug(https://github.com/demo-source/node-app/blob/master/update-package.cjs), and in real-time to replace the type:
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Cannot generate Jest coverage report - Stack Overflow
As a result, I'm using @swc/jest for my tests. All my tests are passing, but the coverage report always comes back empty.
Read more >Command line usage — Coverage.py 6.4.4 documentation
The --no-skip-covered option can be used if needed to see all the files. The --skip-empty switch will skip any file with no executable...
Read more >Empty Jest Coverage Report (Vue.js)
You have empty coverage reports or there are files missing from your coverage report. You've definitely written tests that include those ...
Read more >Full code-coverage with Jest - tsmx
Without this empty suite referencing test-functions.js , Jest would report everything green because there's not even one source file affected, ...
Read more >Generating code coverage for z/OS applications with an Eclipse IDE
To find modules that do not have debug information, export the result to a PDF report and press Settings, select Module as the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please see https://github.com/istanbuljs/esm-loader-hook. This provides an experimental method for getting coverage of node.js ES modules in nyc. Keep in mind the node.js api’s it attaches to are still experimental so the loader hook may break upon release of new versions of node.js.
As an alternative to nyc you might check out https://github.com/bcoe/c8. This option uses native v8 functionality for coverage rather than instrumenting code.
I’m closing this issue as the linked module provides the required support. This is somewhat outside the scope of babel-plugin-istanbul and more within the scope of test runners. Specifically babel-plugin-istanbul does not inject itself into the module loader (CJS or ESM), that is the responsibility of jest,
@babel/register
,@istanbuljs/esm-loader-hook
or other similar loader hooks.