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