Skip to content

Commit c692be7

Browse files
committed
fix: use monocart for e2e coverage to align line counts with vitest
c8's default v8-to-istanbul produces inflated line counts (e.g. 212 vs 57 for the same file) because it maps all source lines including types and imports. monocart-coverage-reports uses AST analysis to count only executable lines, producing line counts within 1-3 of vitest's output. This enables proper Codecov merging of unit + e2e coverage.
1 parent 00b5373 commit c692be7

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"storybook": "turbo watch storybook --filter=@storybook/mcp-internal-storybook",
2626
"test": "vitest",
2727
"test:ci": "NODE_V8_COVERAGE=./e2e-coverage vitest run --coverage --reporter=default --reporter=github-actions --reporter=junit --outputFile=test-report.junit.xml",
28-
"test:ci:report-e2e-coverage": "c8 report --src ./packages --all --exclude-after-remap -n '**/src/**/*.{ts,tsx}' -r lcov --temp-directory ./e2e-coverage -o ./e2e-coverage-report",
28+
"test:ci:report-e2e-coverage": "c8 report --experimental-monocart --temp-directory ./e2e-coverage -r lcov -o ./e2e-coverage-report && node -e \"const fs=require('fs'),p='./e2e-coverage-report/lcov.info';fs.writeFileSync(p,fs.readFileSync(p,'utf8').split('end_of_record\\n').filter(s=>/^SF:.+\\/src\\/.+\\.tsx?$/m.test(s)).join('end_of_record\\n')+'end_of_record\\n')\"",
2929
"test:run": "vitest run",
3030
"turbo": "turbo",
3131
"turbo:test": "turbo run test",
@@ -43,6 +43,7 @@
4343
"@types/node": "20.19.0",
4444
"@vitest/coverage-v8": "4.0.6",
4545
"c8": "^10.1.3",
46+
"monocart-coverage-reports": "^2.12.9",
4647
"oxfmt": "^0.27.0",
4748
"oxlint": "^1.25.0",
4849
"oxlint-tsgolint": "^0.4.0",

pnpm-lock.yaml

Lines changed: 60 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)