Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[istanbul-lib-coverage] After istanbul-lib-coverage merge, unexpected branch not covered at trailing char { #737

Open
loynoir opened this issue Aug 2, 2023 · 1 comment

Comments

@loynoir
Copy link

loynoir commented Aug 2, 2023

Brief

After istanbul-lib-coverage merge, unexpected branch not covered at trailing char {

Description

Run reproduce.mjs with env RUNTIME=node and RUNTIME=browser.

Merge coverage-final.json from different runtime.

Expect 100% coverage.

Actually, branch not covered at trailing char {

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
---------------|---------|----------|---------|---------|-------------------
All files      |     100 |    33.33 |     100 |     100 |                   
 reproduce.mjs |     100 |    33.33 |     100 |     100 | 4-8               
---------------|---------|----------|---------|---------|-------------------
reproduce.mjs:1:const IS_NODE = process.env['RUNTIME'].includes('node')
reproduce.mjs:2:const IS_BROWSER = process.env['RUNTIME'].includes('browser')
reproduce.mjs:3:
reproduce.mjs:4:if (IS_NODE) {
reproduce.mjs:5:  console.log('node')
reproduce.mjs:6:}
reproduce.mjs:7:
reproduce.mjs:8:if (IS_BROWSER) {
reproduce.mjs:9:  console.log('browser')
reproduce.mjs:10:}
reproduce.mjs:11:
reproduce.mjs:12:export { }

Reproduce Repo

https://github.com/loynoir/reproduce-istanbul-lib-coverage-737

Related

https://github.com/ljharb/istanbul-merge/blob/354e660ee6c2a37806d521f90cfaace5eb2a3f4e/bin/istanbul-merge#L36

https://playwright.dev/docs/api/class-coverage

@ljharb
Copy link

ljharb commented Aug 5, 2023

I can reproduce this issue using istanbul-merge, which is a thin wrapper around istanbul.createCoverageMap and .merge, so I think it's a bug with istanbul itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants