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

Branch coverage underreported when merging Jest shards #1581

Open
1 task done
mgoetz-nerdery opened this issue Sep 12, 2024 · 0 comments
Open
1 task done

Branch coverage underreported when merging Jest shards #1581

mgoetz-nerdery opened this issue Sep 12, 2024 · 0 comments

Comments

@mgoetz-nerdery
Copy link

Expected Behavior

I am attempting to run a Jest integration/unit test suite in three parts using the shard flag), then merging the coverage report using nyc merge on the individual shard reports. I expect that the coverage report generated from nyc merge should match the coverage report I get from running the entire test suite at once.

Observed Behavior

The branch coverage generated from nyc merge is slightly underreported.

Example of the branch coverage reported by nyc merge:
Screenshot 2024-09-12 at 11 22 34 AM

Example of the branch coverage reported by running the entire test suite:
Screenshot 2024-09-12 at 11 25 27 AM

The merged coverage report incorrectly shows that the different branches are not covered, even though the individual lines are taken are of.

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config
  1. Generate the individual shards using this: node --expose-gc --no-compilation-cache $(yarn bin jest) --ci --colors --logHeapUsage --reporters=default --reporters=github-actions --reporters=jest-junit --coverage --coverageReporters=cobertura --coverageReporters=text-summary --coverageReporters=html --coverageReporters=json --shard=X/3
  2. Move the coverage-final.json files from each shard into the same folder
  3. Run nyc merge shardcoverage nycoutput/output.json and nyc report -t nycoutput --report-dir final-report --reporter=lcov --reporter=text-summary --reporter=cobertura --reporter=html

.nycrc:

{
  "cache": false,
  "check-coverage": true,
  "functions": "85"
}

Environment Information

  System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.22 GB / 32.00 GB
  Binaries:
    Node: 20.11.1 - /usr/local/bin/node
    Yarn: 3.6.3 - /usr/local/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
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

1 participant