question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty coverage report when using "type": "module"

See original GitHub issue

Empty 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
coreyfarrellcommented, Mar 21, 2020

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.

0reactions
coreyfarrellcommented, Nov 29, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found