Goal: Block bad code from merging to develop using automated tests
Solution: Fix existing Playwright tests to run in CI headless mode
Time: 2-3 hours
Files to change: 2 files (tests/smoke_echokit.py, .github/workflows/test.yml)
tests/smoke_echokit.py (Line ~102)# Before:
context = p.chromium.launch_persistent_context(
"",
headless=False, # ❌ Doesn't work in CI
args=[...]
)
# After:
context = p.chromium.launch_persistent_context(
"",
channel='chromium', # ✅ Enables headless extensions
headless=True,
args=[...]
)
.github/workflows/test.yml (Line ~22)# Before:
smoke:
runs-on: ubuntu-latest
if: false # ❌ Tests disabled
# After:
smoke:
runs-on: ubuntu-latest
# ✅ Tests enabled
Settings → Branches → develop → Branch protection rules:
smoke, validate# Run locally (headed mode for debugging)
HEADLESS=false python3 tests/smoke_echokit.py
# Run locally (headless, same as CI)
python3 tests/smoke_echokit.py
# Run with Playwright UI inspector
PWDEBUG=1 python3 tests/smoke_echokit.py
# Install dependencies
pip install playwright
python -m playwright install chromium
After implementing Phase 1:
Local Testing (before pushing):
python3 tests/smoke_echokit.py passesCI Testing (after pushing):
developvalidate job passes (~10s)smoke job passes (~90s)Failure Testing:
validate job failsFix: Add explicit wait
# In smoke_echokit.py
sw = context.wait_for_event('serviceworker', timeout=30000)
Fix: Use channel='chromium' for headless compatibility
context = p.chromium.launch_persistent_context(
"",
channel='chromium', # ← Add this
headless=True,
args=[...]
)
Fix: Check branch protection rules
develop rulesmoke is in required status checksFix: Add explicit waits instead of sleeps
# ❌ Bad
time.sleep(1)
page.click('button')
# ✅ Good
page.wait_for_selector('button', state='visible')
page.click('button')
developshared/matcher.js, shared/app.jsDocumentation:
CHROME_EXTENSION_CI_CD_TESTING_RESEARCH.mdCI_CD_IMPLEMENTATION_GUIDE.mdTESTING_FRAMEWORK_COMPARISON.mdTESTING_RESEARCH_SUMMARY.mdExternal Resources:
Getting Stuck?:
PWDEBUG=1 to debugheadless=False locally to see what’s happeningCI_CD_IMPLEMENTATION_GUIDE.md troubleshootingtests/smoke_echokit.pychannel='chromium', headless=True.github/workflows/test.ymlif: false from smoke jobpython3 tests/smoke_echokit.py
git checkout -b test/ci-tests
git add tests/smoke_echokit.py .github/workflows/test.yml
git commit -m "fix: enable CI smoke tests with headless mode"
git push origin test/ci-tests
developdevelopsmoke and validate checksDone! ✅ Tests now block bad PRs from merging.
Last Updated: 2026-05-12
Estimated ROI: 10x reduction in production bugs
Cost: $0 (all free tools)