You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I didn't open the original issue so it's possible I've missed something or that this doesn't completely solve the Jest issue, but this overall does seem like a good enhancement for nyc.
Currently when generating a coverage report nyc seems to base it on the first common root of the files in the report e.g. in my reproduction there are two coverage maps that were generated from the original reproduction repo (on the jest issue) just with no code in the index.js and file.js files to make the maps as small as possible - coverage-map-one-file.json is generated by running jest file --coverage and coverage-map-two-file.json is generated by running jest --coverage.
If you call index.js coverage-map-one-file.json it'll generate an html coverage report with this structure:
This can be confusing, because the contents of the coverage dir are not automatically wiped (at least by nyc) so if you're refreshing the html report in your browser you could end up seeing the old coverage, and likewise can run into 404s if it is wiped.
The desired behaviour (which this issue is about) is that both of these coverage reports should have file.js.html located in src, which I believe can be achieved by allowing nyc to be passed a rootDir option that sets that "first common root" - that way external tools like jest (who typically know where the root of the project is) can have nyc generate a consistent output regardless of what files are actually being covered.
I can help try and implement this.
The text was updated successfully, but these errors were encountered:
This is stemming from jestjs/jest#7176 which I've created a
jest
-free reproduction for here: https://github.com/G-Rath/jest-istanbul-repoI didn't open the original issue so it's possible I've missed something or that this doesn't completely solve the Jest issue, but this overall does seem like a good enhancement for nyc.
Currently when generating a coverage report
nyc
seems to base it on the first common root of the files in the report e.g. in my reproduction there are two coverage maps that were generated from the original reproduction repo (on the jest issue) just with no code in theindex.js
andfile.js
files to make the maps as small as possible -coverage-map-one-file.json
is generated by runningjest file --coverage
andcoverage-map-two-file.json
is generated by runningjest --coverage
.If you call
index.js coverage-map-one-file.json
it'll generate an html coverage report with this structure:If you call
index.js coverage-map-two-file.json
it'll generate an html coverage report with this structure:This can be confusing, because the contents of the
coverage
dir are not automatically wiped (at least bynyc
) so if you're refreshing the html report in your browser you could end up seeing the old coverage, and likewise can run into 404s if it is wiped.The desired behaviour (which this issue is about) is that both of these coverage reports should have
file.js.html
located insrc
, which I believe can be achieved by allowingnyc
to be passed arootDir
option that sets that "first common root" - that way external tools likejest
(who typically know where the root of the project is) can havenyc
generate a consistent output regardless of what files are actually being covered.I can help try and implement this.
The text was updated successfully, but these errors were encountered: