istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.59k stars 359 forks source link

nyc@15 doesn't report coverage anymore #1512

Closed ericmorand closed 1 year ago

ericmorand commented 1 year ago

A few hours ago, nyc@15 stopped reporting coverage at all, without any change to our projects.

To illustrate the issue, I created a repository:

https://github.com/ericmorand/nyc-issue

It comes with two branches: main, fueled by nyc@14; nyc-15 fueled by nyc@15.

To run the coverage script, just execute npm t.

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |       80 |       50 |      100 |       75 |                   |
 foo.ts   |       80 |       50 |      100 |       75 |                 3 |
----------|----------|----------|----------|----------|-------------------|
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

I strongly suspect that this is due to the release of @babel/core, which istanbul-lib-instrument depends on and that was upgraded to 7.21.0 a few hours ago, but I'm still investigating.

ericmorand commented 1 year ago

As suspected, the issue was coming from babel - but namely from@babel/generator@7.21.0 that came with a bug related to source maps:

https://github.com/babel/babel/issues/15444

It was fixed in @babel/generator@7.21.1, which is now installed alongside nyc@15, which fixes this issue.