feat : configure vitest test coverage#139
Conversation
📝 WalkthroughWalkthroughThe PR adds a coverage-enabled Vitest script and configuration, updates CI to run coverage, and enables core-js builds in the workspace. ChangesCoverage execution changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm-workspace.yaml`:
- Line 2: The build-script allowlist currently includes core-js unnecessarily;
remove core-js from the allowlist in the workspace config so only packages with
a justified install failure are kept. Update the pnpm workspace allowlist entry
directly, and leave `@vitest/coverage-v8` out since it does not need lifecycle
scripts and core-js postinstall is unrelated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 36a1b3ad-c6ab-4a4f-86b2-49485fffaf01
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (4)
.github/workflows/ci.ymlpackage.jsonpnpm-workspace.yamlvitest.config.ts
| @@ -1,5 +1,5 @@ | |||
| allowBuilds: | |||
| core-js: false | |||
| core-js: true | |||
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor
🧩 Analysis chain
🌐 Web query:
Does the current core-jspackage execute a lifecycle or postinstall script during installation, and is enabling pnpm build scripts forcore-jsnormally required when adding Vitest coverage with@vitest/coverage-v8?
💡 Result:
Yes, the core-js package executes a postinstall script [1][2]. This script, located in the package as postinstall.js, is primarily used to display a message to users about the project [1][3][4]. Regarding your second question, enabling pnpm build scripts for core-js is not normally required specifically for adding Vitest coverage with @vitest/coverage-v8. Vitest with the @vitest/coverage-v8 provider performs code coverage collection at runtime by instructing the V8 engine, which does not require your dependencies to undergo custom build or instrumentation steps during the installation process [5]. While pnpm may restrict package lifecycle scripts (such as postinstall) by default for security, this restriction is independent of the functional requirements of Vitest coverage [2][6]. If your environment or pnpm configuration blocks the core-js postinstall script, you may need to explicitly approve it to ensure the package is installed as intended, but this is a package management configuration, not a requirement for enabling Vitest coverage itself [2][6].
Citations:
- 1: https://github.com/zloirock/core-js/blob/master/packages/core-js/postinstall.js
- 2: npm RFC #868 will block this package's install script by default zloirock/core-js#1542
- 3: https://github.com/zloirock/core-js?tab=readme-ov-file
- 4: https://corejs-doc.netlify.app/guide/
- 5: https://vitest.dev/guide/coverage
- 6: https://pnpm.io/cli/approve-builds
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== pnpm-workspace.yaml ==\n'
cat -n pnpm-workspace.yaml
printf '\n== core-js mentions in repo ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '\bcore-js\b' .
printf '\n== package.json files mentioning vitest or coverage-v8 ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '"`@vitest/coverage-v8`"|vitest|coverage-v8' --glob 'package.json' .
printf '\n== package.json files mentioning core-js ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '"core-js"' --glob 'package.json' .Repository: DataDave-Dev/weftmap
Length of output: 851
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import pathlib, re, json
p = pathlib.Path('pnpm-workspace.yaml')
print(p.read_text())
PYRepository: DataDave-Dev/weftmap
Length of output: 242
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== pnpm-workspace.yaml ==\n'
cat -n pnpm-workspace.yaml
printf '\n== core-js mentions in repo ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '\bcore-js\b' .
printf '\n== package.json files mentioning vitest or coverage-v8 ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '"`@vitest/coverage-v8`"|vitest|coverage-v8' --glob 'package.json' .
printf '\n== package.json files mentioning core-js ==\n'
rg -n --hidden --glob '!**/node_modules/**' --glob '!**/.git/**' '"core-js"' --glob 'package.json' .Repository: DataDave-Dev/weftmap
Length of output: 851
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import pathlib
print(pathlib.Path('pnpm-workspace.yaml').read_text())
PYRepository: DataDave-Dev/weftmap
Length of output: 242
Keep core-js off the build-script allowlist unless there’s a separate install failure to justify it. @vitest/coverage-v8 doesn’t need lifecycle scripts, and core-js’s postinstall is unrelated to coverage. pnpm-workspace.yaml:2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pnpm-workspace.yaml` at line 2, The build-script allowlist currently includes
core-js unnecessarily; remove core-js from the allowlist in the workspace config
so only packages with a justified install failure are kept. Update the pnpm
workspace allowlist entry directly, and leave `@vitest/coverage-v8` out since it
does not need lifecycle scripts and core-js postinstall is unrelated.
Vitest Code Coverage Analysis ReportThis document provides a comprehensive breakdown and strategic analysis of the code coverage report generated for the 📈 Executive Summary
🔍 Detailed Coverage Breakdown🟢 1. High Coverage Modules (Well-Tested)These files represent the strongest parts of the test suite. No immediate actions are needed here.
🟡 2. Partially Covered Modules (Actions Needed)These modules require additional unit test scenarios to cover missed lines and conditional branches. 🐍 Python Analyzer (
|
Description
This PR implements test coverage reporting using Vitest's v8 provider both locally and within the GitHub Actions
CI pipeline, resolving issue #64.
Changes Made:
• v8 as the provider.
• Outputs in text , json , and html formats.
• Included all source code files while excluding test files and type definitions.
of pnpm test , ensuring coverage summaries are printed during checks.
How to test locally
pnpm installto update your dependencies.pnpm test:coverageto execute the tests and print the coverage report table in your terminal.Summary by CodeRabbit
Tests
Chores