Open loynoir opened 1 year ago
How exactly do i run reproduce.js
so that it produces coverage data?
@ljharb
Below script simulate collect coverage from different runtime.
https://github.com/loynoir/reproduce-istanbul-lib-coverage-737/blob/main/test.sh
And c8 is a wrapper for NODE_V8_COVERAGE=dir
On node v20.5.0, everything seems to work just fine, including the nyc command. What version of node are you using?
$ git clean -dfx > /dev/null
$
$ node --version
v20.4.0
$ npm i && bash ./test.sh
added 261 packages, and audited 262 packages in 5s
70 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
+ env RUNTIME=node,browser npm exec -- c8 --report-dir build/expected node ./reproduce.mjs
node
browser
---------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
reproduce.mjs | 100 | 100 | 100 | 100 |
---------------|---------|----------|---------|---------|-------------------
+ env RUNTIME=node npm exec -- c8 --report-dir build/actual/node node ./reproduce.mjs
node
---------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files | 83.33 | 50 | 100 | 83.33 |
reproduce.mjs | 83.33 | 50 | 100 | 83.33 | 9-10
---------------|---------|----------|---------|---------|-------------------
+ env RUNTIME=browser npm exec -- c8 --report-dir build/actual/browser node ./reproduce.mjs
browser
---------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files | 83.33 | 50 | 100 | 83.33 |
reproduce.mjs | 83.33 | 50 | 100 | 83.33 | 5-6
---------------|---------|----------|---------|---------|-------------------
+ mkdir -p ./build/actual/temp
+ npm exec -- istanbul-merge --out ./build/actual/temp/coverage.json ./build/actual/node/coverage-final.json ./build/actual/browser/coverage-final.json
+ npm exec -- nyc report -r lcov -r text --temp-directory ./build/actual/temp --report-dir ./build/actual
---------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files | 100 | 33.33 | 100 | 100 |
reproduce.mjs | 100 | 33.33 | 100 | 100 | 4-8
---------------|---------|----------|---------|---------|-------------------
$
ohhh right sorry, it's not that it errors, it's that there's 4 uncovered lines :eyes:
All this package is doing is wrapping istanbul's istanbul.createCoverageMap
, and using .merge
on it. I think this is a bug in istanbul.
Description
Run
reproduce.mjs
with envRUNTIME=node
andRUNTIME=browser
.Merge
coverage-final.json
from different runtime.Expect 100% coverage.
Actually,
branch not covered
at trailing char{
Reproduce Repo
https://github.com/loynoir/reproduce-istanbul-lib-coverage-737
Related https://github.com/istanbuljs/istanbuljs/issues/737
https://playwright.dev/docs/api/class-coverage