Skip to content

Latest commit

 

History

History
289 lines (229 loc) · 7.04 KB

File metadata and controls

289 lines (229 loc) · 7.04 KB

Coverage Implementation Verification Checklist

Use this checklist to verify the test coverage reporting and threshold enforcement is working correctly.

✅ Configuration Verification

Jest Configuration

  • jest.config.js contains coverageReporters array
  • coverageDirectory is set to 'coverage'
  • coverageThreshold.global has all four metrics at 30%
  • collectCoverageFrom includes src/**/*.js
  • collectCoverageFrom excludes scripts and config

Package.json Scripts

  • test script runs jest
  • test:coverage script runs jest with --coverage
  • test:coverage:ci script includes --ci and --maxWorkers flags
  • check-coverage script points to scripts/check-coverage.js

CI/CD Workflows

  • .github/workflows/coverage.yml exists
  • Coverage workflow runs on PR and push to main/develop
  • Workflow includes environment variables (MOCK_STELLAR, API_KEYS)
  • Workflow uploads coverage artifacts
  • .github/workflows/ci.yml includes coverage job

✅ Functional Verification

Local Testing

1. Generate Coverage Report

cd Stellar-Micro-Donation-API
npm run test:coverage

Verify:

  • Tests run successfully
  • Coverage summary appears in terminal
  • coverage/ directory is created
  • coverage/lcov-report/index.html exists
  • coverage/lcov.info exists
  • coverage/coverage-summary.json exists

2. Check Coverage Thresholds

npm run check-coverage

Verify:

  • Script runs without errors
  • Shows coverage for all 4 metrics
  • Displays pass/fail status for each metric
  • Shows minimum threshold (30%) for each metric
  • Exits with code 0 if all pass

3. View HTML Report

# macOS
open coverage/lcov-report/index.html

# Windows
start coverage/lcov-report/index.html

# Linux
xdg-open coverage/lcov-report/index.html

Verify:

  • HTML report opens in browser
  • Shows file list with coverage percentages
  • Can navigate to individual files
  • Uncovered lines highlighted in red
  • Covered lines highlighted in green
  • Branch coverage indicators visible

CI/CD Testing

1. Create Test Branch

git checkout -b test/coverage-verification
git push origin test/coverage-verification

Verify:

  • Coverage workflow triggers automatically
  • Workflow appears in GitHub Actions tab

2. Check Workflow Execution

Navigate to GitHub Actions → Coverage workflow

Verify:

  • Workflow runs to completion
  • "Run tests with coverage" step succeeds
  • Coverage summary visible in logs
  • "Upload coverage report" step succeeds
  • Artifact appears in workflow summary

3. Download Coverage Artifact

Click on coverage-report artifact in workflow

Verify:

  • Artifact downloads successfully
  • Contains lcov-report directory
  • Contains lcov.info file
  • Contains coverage-summary.json

4. Test Threshold Enforcement

Temporarily lower threshold in jest.config.js to 99%:

coverageThreshold: {
  global: {
    branches: 99,
    functions: 99,
    lines: 99,
    statements: 99,
  },
}

Commit and push:

git add jest.config.js
git commit -m "Test: Lower thresholds to verify enforcement"
git push

Verify:

  • Coverage workflow runs
  • Workflow fails (red X)
  • Error message indicates threshold not met
  • Build is blocked

Revert changes:

git revert HEAD
git push

Verify:

  • Workflow runs again
  • Workflow succeeds (green checkmark)

✅ Documentation Verification

Files Exist

  • docs/COVERAGE_GUIDE.md exists
  • docs/COVERAGE_IMPLEMENTATION_COMPLETE.md exists
  • COVERAGE_QUICK_REFERENCE.md exists
  • TASK_COMPLETION_SUMMARY.md exists
  • COVERAGE_VERIFICATION_CHECKLIST.md exists (this file)

README Updated

  • Testing section includes coverage commands
  • Contributing section mentions coverage requirements
  • Links to coverage documentation present

Documentation Content

  • Coverage guide explains all metrics
  • Guide includes troubleshooting section
  • Implementation doc lists all modified files
  • Quick reference has essential commands
  • Task summary confirms acceptance criteria met

✅ Integration Verification

Git Integration

  • coverage/ directory in .gitignore
  • Coverage reports not committed to repo
  • Only configuration files tracked

Developer Workflow

Test the complete developer workflow:

  1. Make a code change
  2. Run npm test
  3. Run npm run test:coverage
  4. Run npm run check-coverage
  5. View HTML report
  6. Commit changes
  7. Push to GitHub
  8. Create PR

Verify:

  • All commands work without errors
  • Coverage workflow runs on PR
  • PR shows coverage status
  • Can merge if coverage passes

✅ Edge Cases

Test Coverage Drop

Create a new file without tests:

echo "function untested() { return true; }" > src/untested.js
git add src/untested.js
git commit -m "Add untested code"
git push

Verify:

  • Coverage workflow runs
  • Coverage percentage drops
  • If below 30%, build fails
  • Clear error message shown

Clean up:

git revert HEAD
git push

Missing Coverage File

rm -rf coverage
npm run check-coverage

Verify:

  • Script detects missing coverage file
  • Shows error message
  • Suggests running npm run test:coverage
  • Exits with non-zero code

Regenerate:

npm run test:coverage

✅ Performance Verification

Local Performance

time npm run test:coverage

Verify:

  • Completes in reasonable time (< 2 minutes)
  • No memory issues
  • All reports generated

CI Performance

Check workflow execution time in GitHub Actions

Verify:

  • Coverage job completes in < 5 minutes
  • No timeout issues
  • Artifact upload succeeds

📊 Final Verification

All Acceptance Criteria Met

  • ✅ Coverage report generated on test run
  • ✅ Builds fail if coverage drops below thresholds

All Tasks Completed

  • ✅ Coverage tooling configured
  • ✅ Minimum thresholds defined (30%)
  • ✅ CI/CD integration complete
  • ✅ Documentation created

Quality Checks

  • No syntax errors in configuration files
  • No broken links in documentation
  • All scripts executable
  • All workflows valid YAML

🎉 Verification Complete

If all items are checked, the test coverage reporting and threshold enforcement implementation is complete and working correctly!

🐛 Troubleshooting

If any verification fails:

  1. Check error messages - They usually indicate the issue
  2. Review logs - GitHub Actions logs show detailed output
  3. Verify configuration - Ensure all config files match documentation
  4. Check dependencies - Run npm install to ensure all packages installed
  5. Consult documentation - See docs/COVERAGE_GUIDE.md for help

📞 Support

For issues:

  • Review docs/COVERAGE_GUIDE.md troubleshooting section
  • Check GitHub Actions workflow logs
  • Verify all configuration files
  • Ensure Node.js and npm are up to date