-
Notifications
You must be signed in to change notification settings - Fork 1
Description
name: Implement proper code coverage instrumentation for VS Code extension
status: open
created: 2025-11-29T16:56:00Z
updated: 2025-11-29T16:56:00Z
github: #66
depends_on: [2, 3, 4]
parallel: false
conflicts_with: []
Task: Implement proper code coverage instrumentation for VS Code extension
Description
The CI/CD pipeline is working with all 11 tests passing on all platforms (Linux, macOS, Windows). However, code coverage is currently at 0% because standard nyc/istanbul instrumentation doesn't work with VS Code extensions. Extension code runs inside VS Code's Electron process, not directly in Node.js, so the code must be instrumented BEFORE VS Code loads it.
This task involves implementing proper coverage instrumentation for the VS Code extension and raising coverage thresholds back to the target 90%.
Problem Context
During CI/CD implementation, we encountered a fundamental limitation: VS Code extensions have unique coverage requirements because code runs inside VS Code's Electron process. The nyc tool wraps the test runner but cannot instrument code that VS Code loads internally. After 8 debugging iterations, we got all tests passing but had to temporarily lower coverage thresholds to 0% to get the pipeline green.
Acceptance Criteria
- Code coverage accurately reflects executed code in VS Code environment (>0%)
- Coverage reports show actual line/branch/function coverage
- Coverage thresholds raised to 90% for all metrics (lines, statements, functions, branches)
- CI/CD pipeline enforces 90% coverage (fails if below threshold)
- Coverage reports generated and uploaded to Codecov
- All existing 11 tests continue to pass on all platforms
- HTML coverage report viewable locally
- Documentation updated with VS Code coverage implementation details
Technical Details
Option 1: Webpack Plugin for Instrumentation (Recommended)
Use istanbul-instrumenter-loader to instrument code during webpack build:
npm install --save-dev istanbul-instrumenter-loader @jsdevtools/coverage-istanbul-loaderUpdate webpack.config.js to add instrumentation in coverage mode:
{
test: /\.ts$/,
use: [
{ loader: '@jsdevtools/coverage-istanbul-loader' },
{ loader: 'ts-loader' }
]
}Option 2: c8 (Modern V8 Coverage)
Replace nyc with c8 which uses V8's native coverage:
npm install --save-dev c8Update package.json:
{
"test:coverage": "c8 node ./out/test/runTest.js"
}Files to Modify
vscode-extension/webpack.config.js- Add instrumentation loadervscode-extension/.nycrc.json- Update thresholds from 0% to 90%vscode-extension/package.json- Update coverage scripts, add dependencies.github/workflows/ci.yml- May need to use instrumented build for coverage job.github/CI_CD.md- Document VS Code coverage setupvscode-extension/README.md- Update coverage instructions
Dependencies
- TypeScript configuration (Task Initialize extension project with TypeScript + webpack config #2)
- Testing infrastructure (Task Configure testing infrastructure (Mocha, Sinon, nyc) #3)
- CI/CD pipeline (Task Setup CI/CD pipeline with coverage gates (90%+ enforcement) #4)
- Actual extension functionality implemented (recommended before this task)
Effort Estimate
- Size: M
- Hours: 4 hours
- Research & setup: 1 hour
- Implementation: 2 hours
- CI integration: 1 hour
- Documentation: 30 minutes (included)
- Parallel: false (blocks on CI/CD being complete)
Testing Strategy
- Local Testing: Run
npm run test:coverageand verify >0% coverage - Add Test Function: Add simple function to extension.ts, verify coverage changes
- CI Testing: Push to branch, verify coverage uploaded to Codecov
- Threshold Testing: Intentionally lower coverage to verify 90% enforcement works
Definition of Done
- Code implemented with chosen approach (webpack plugin or c8)
- Coverage accurately reflects code execution (>0% for extension.ts)
- All 11 tests passing with 90% coverage thresholds enforced
- CI pipeline green with coverage reports uploaded
- Documentation updated in all relevant files
- Code reviewed
- Local coverage workflow documented and tested
Notes
- Should be tackled AFTER actual extension functionality is implemented
- No point achieving 90% coverage of empty skeleton
- Infrastructure should be in place for automatic enforcement as features are added
- Priority: High (blocks proper quality gates) but not urgent (no functionality yet)
Related Tasks
- Task Initialize extension project with TypeScript + webpack config #2: Extension initialization (completed)
- Task Configure testing infrastructure (Mocha, Sinon, nyc) #3: Testing infrastructure (completed)
- Task Setup CI/CD pipeline with coverage gates (90%+ enforcement) #4: CI/CD pipeline (completed)
References
- VS Code Extension Testing
- Istanbul Instrumenter Loader
- c8 Documentation
- Analysis:
/workspaces/formaltask/doc/vscode-extension-cicd-detailed-analysis.md