Skip to content

Implement Proper Code Coverage Instrumentation for VS Code Extension #66

@johnproblems

Description

@johnproblems

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-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

  1. Local Testing: Run npm run test:coverage and verify >0% coverage
  2. Add Test Function: Add simple function to extension.ts, verify coverage changes
  3. CI Testing: Push to branch, verify coverage uploaded to Codecov
  4. 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

References

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions