Code Coverage Pipeline & Discord Improvements
Date: January 14, 2026
Status: ✅ Complete
Summary
Implemented two major improvements:
- Custom code coverage pipeline - No more Playwright browser testing issues
- Enhanced Discord deployment messages - Shows exactly what failed
1. Custom Code Coverage Pipeline ✅
Problem Solved
npm test:coverage was failing due to:
- ❌ Playwright browser installation issues (missing system dependencies)
- ❌ Storybook vitest addon conflicts with coverage mode
- ❌ Browser mode conflicts with jsdom environment
Solution Implemented
Simplified test configuration:
- Removed Playwright browser testing from vitest config
- Disabled Storybook vitest plugin for code coverage
- Set up jsdom environment for DOM testing
- Enhanced test.setup.js with proper mocks
Files Changed
vitest.config.js
- Removed Playwright browser mode
- Set environment to
jsdom - Simplified plugin configuration
test.setup.js
- Added DOM mocking (IntersectionObserver, matchMedia)
- Added cleanup after each test
- Added jsdom polyfills
package.json
- Added
@testing-library/user-eventdependency
- Added
New GitHub Actions Workflow
Created: .github/workflows/coverage.yml
- Generates code coverage reports automatically
- Creates coverage badges (visual indicators)
- Uploads coverage reports to artifacts
- Comments on PRs with coverage summary
- Validates against coverage thresholds (configurable)
How to Use It
Local testing:
bash
# Run tests with coverage report
npm run test:coverage
# Output: displays coverage percentages
# Creates coverage/html/index.html for detailed reportIn GitHub:
- Coverage workflow runs on every push to
dev/mainand on PRs - Generates artifacts in
coverage/directory - PR comments show coverage changes
- Links to full HTML coverage report
Coverage Output
Test Files 3 passed (3)
Tests 13 passed (13)
% Coverage report from v8
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 78.49 | 54.28 | 90 | 79.77 |
src/firebase.js | 64 | 28.57 | 100 | 64.58 |
src/components... | 80 | 75 | 100 | 100 |
-------------------|---------|----------|---------|---------|-------------------2. Enhanced Discord Deployment Messages ✅
What Changed
Before:
**App:** ✅
**Storybook:** ❌
**Docs:** ✅
**Firebase:** ✅After:
**Services:**
• App: ✅ [dev.ourlantern.app](https://dev.ourlantern.app)
• Storybook: ❌ Failed
• Docs: ✅ [docs.dev.ourlantern.app](https://docs.dev.ourlantern.app)
• Firebase: ✅ Rules & Indexes Deployed
**Failures:**
• Storybook: failureImprovements
- Service links are clickable - Direct links to deployed services in Discord
- Clear failure indicators - Shows which services actually failed
- Detailed failure reasons - Lists failure types (success, failure, skipped)
- Links to failed workflow - Click through to GitHub Actions for logs
Files Modified
.github/workflows/deploy-dev.yml
- Enhanced status determination
- Tracks failure reasons
- Better formatted Discord message
- Link to GitHub Actions run
.github/workflows/deploy-prod.yml
- Same improvements as dev
- Uses DISCORD_WEBHOOK_PROD_DEPLOY
Discord Message Example
Success Message:
🚀 Development Deployment ✅ Success
Environment: Development
Branch: dev
Commit: abc1234
Services:
• App: ✅ [dev.ourlantern.app](https://dev.ourlantern.app)
• Storybook: ✅ [storybook.dev.ourlantern.app](...)
• Docs: ✅ [docs.dev.ourlantern.app](...)
• Firebase: ✅ Rules & Indexes Deployed
Deployed by: @usernameFailure Message:
🚀 Development Deployment ❌ Failed
Environment: Development
Branch: dev
Commit: abc1234
Services:
• App: ✅ [dev.ourlantern.app](...)
• Storybook: ❌ Failed
• Docs: ✅ [docs.dev.ourlantern.app](...)
• Firebase: ❌ Rules/Indexes Failed
Failures:
• Storybook: failure
• Firebase Rules: failure
Deployed by: @usernameHow It Works
Code Coverage Workflow
Push to dev/main or PR
↓
Run tests with coverage (npm run test:coverage)
↓
Generate reports (HTML, JSON, LCOV)
↓
Create coverage badge
↓
Upload artifacts
↓
(Optional) Comment on PR with summary
↓
Validate against thresholdsDiscord Notification Flow
Deployment Jobs (App, Storybook, Docs, Firebase)
↓
Check each job's result status
↓
Build list of failures if any
↓
Create formatted Discord message with:
- Overall status (✅ or ❌)
- Each service with link
- Failure details if any
- Link to GitHub Actions
↓
Send to Discord webhookConfiguration
Code Coverage Thresholds
Edit coverage.yml to set thresholds:
yaml
- name: Check coverage thresholds
run: |
THRESHOLD=50 # Change this number
# Current: 50% (MVP threshold)
# Recommended for beta: 70%
# Recommended for production: 80%Discord Webhook Secrets
Make sure these are set in GitHub (Settings → Secrets):
DISCORD_WEBHOOK_COMMITS- For commit notificationsDISCORD_WEBHOOK_DEV_DEPLOY- For dev deploymentsDISCORD_WEBHOOK_PROD_DEPLOY- For prod deployments
Testing the Setup
Test Code Coverage Locally
bash
cd /home/mechelle/repos/lantern_app
npm run test:coverageExpected output:
- ✅ Tests run successfully
- ✅ Coverage report generated
- ✅ HTML report at
coverage/index.html
Test Discord Messages
Push a commit to dev branch:
- Check
#commitschannel → should see commit notification - Wait for deployment to complete
- Check
#deploymentschannel → should see deployment status
Files Summary
Modified:
vitest.config.js ← Simplified config
test.setup.js ← DOM setup
.github/workflows/deploy-dev.yml ← Enhanced Discord
.github/workflows/deploy-prod.yml ← Enhanced Discord
package.json ← Added test-library user-event
Created:
.github/workflows/coverage.yml ← New coverage pipelineNext Steps
Immediate (Now)
- ✅ Test
npm run test:coveragelocally - ✅ Verify Discord messages show failures properly
- ✅ Check coverage reports in artifacts
Short Term (Before Beta)
- [ ] Set coverage threshold (currently 50%)
- [ ] Review failed deployment messages in Discord
- [ ] Test rollback procedure
Medium Term (Beta Launch)
- [ ] Increase coverage threshold to 70%+
- [ ] Add more unit tests
- [ ] Consider CODECOV_TOKEN if coverage tracking needed
Troubleshooting
Tests still failing with "document is not defined"
Fix: Make sure environment: 'jsdom' is in vitest.config.js
Coverage reports not generating
Check:
- No syntax errors in coverage.yml
- Tests are passing (at least 1 passing test)
- Check GitHub Actions logs for errors
Discord messages not showing failure details
Check:
- Webhook URLs are valid (DISCORD_WEBHOOK_DEV_DEPLOY, etc.)
- Discord servers haven't rate-limited us
- Try manually posting to test webhook
Coverage artifact not uploading
Check:
- Tests completed (even if some failed)
- Coverage directory exists at
coverage/ - Retention days not set to 0