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.

[Bug]: V8 coverage does not work with native ESM

See original GitHub issue

Version

27.2.0

Steps to reproduce

As it was mentioned in https://github.com/facebook/jest/issues/9430#issuecomment-924826080, I was trying out V8 coverage with native ESM. Babel coverage works well, but for some reason there are issues with V8 coverage.

I was testing:

  • ESM without transforming, hence without source maps included
  • TypeScript modules transformed into ESM with source maps included

@SimenB thanks for quick response and hints. I started from creating failing tests inside a clone of Jest repo. The same result – coverage works well with Babel, but not with V8. So I will dig into the code and will try to find the reason.

Expected behavior

I also tried out coverage using c8 module directly on an ESM file (without involving Jest). All is good. Quick, nice and precise.

Similar result is expected.

Actual behavior

V8 coverage reports seems to be buggy.

Additional context

No response

Environment

System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  Binaries:
    Node: 16.9.1 - /usr/local/bin/node
    Yarn: 2.4.3 - /usr/local/bin/yarn
    npm: 7.21.1 - /usr/local/bin/npm

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bompuscommented, Sep 22, 2021

I’m also experiencing this on 27.2.1 with --coverage=true --coverageProvider=v8. I didn’t check covered lines closely, but uncovered lines are off by ~3 lines it seems.

Running through c8 and using --coverage=false on jest, the uncovered line numbers are correct.

0reactions
github-actions[bot]commented, Oct 26, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js v19.3.0 Documentation
Bugs found in legacy features are unlikely to be fixed. Use caution when making use of Experimental features, particularly within modules. Users may...
Read more >
Babel Roadmap
When we move to ESM, it will be hard to resolve and load plugin synchronously in transformSync . This prevents it from being...
Read more >
ts-node - npm
ts-node is a TypeScript execution engine and REPL for Node.js. ... CommonJS supports extensionless files but native ESM does not.
Read more >
jestjs - unit test mock - node 17 + typescript + ESM module
Can I implement mock for one function only? or module? ... Developments in ESM support in jest is blocked due to 2 bugs...
Read more >
Source maps in Node.js. Supporting the many flavors of…
As the variable name suggests, source map support was initially added to address a problem with native V8 code coverage; tools like ts-node ......
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