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
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-loader
Update 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 c8
Update package.json:
{
"test:coverage": "c8 node ./out/test/runTest.js"
}
Files to Modify
vscode-extension/webpack.config.js - Add instrumentation loader
vscode-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 setup
vscode-extension/README.md - Update coverage instructions
Dependencies
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:coverage and 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
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
References
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
Technical Details
Option 1: Webpack Plugin for Instrumentation (Recommended)
Use istanbul-instrumenter-loader to instrument code during webpack build:
Update
webpack.config.jsto add instrumentation in coverage mode:Option 2: c8 (Modern V8 Coverage)
Replace nyc with c8 which uses V8's native coverage:
Update 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 instructionsDependencies
Effort Estimate
Testing Strategy
npm run test:coverageand verify >0% coverageDefinition of Done
Notes
Related Tasks
References
/workspaces/formaltask/doc/vscode-extension-cicd-detailed-analysis.md