QA Test Healer
Purpose
Automatically fix broken tests after code changes. Inspired by fugazi/test-automation-skills-agents, this skill runs failing tests in headed/debug mode, analyzes failures, applies targeted fixes, and either restores passing tests or marks unfixable cases as test.fixme() with a clear explanation.
Trigger Phrases
- "Heal my failing tests"
- "Fix broken Playwright/Cypress tests"
- "Auto-fix test failures"
- "Tests are failing after my changes"
- "Debug and fix selector/assertion failures"
- "Run failing test and fix it"
Healing Workflow
- Receive failing test(s) — User provides failing test path(s), error output, or CI failure logs
- Run test in headed mode / with debug output — Execute the test with visible browser and verbose logging to capture failure context
- Analyze failure — Determine root cause: selector broken? assertion changed? timeout? missing element? network change?
- Apply fix strategy — Use the appropriate strategy from
references/fix-strategies.md
- Re-run to verify fix — Execute the test again; confirm it passes
- If unfixable — Mark as
test.fixme('explanation') with a clear reason for manual review
Fix Strategies
| Failure Type |
Strategy |
Action |
| Broken selectors |
Find new locator |
Use accessibility snapshot (Playwright MCP) to inspect DOM; update POM/test with stable locator (getByRole, getByTestId preferred) |
| Changed assertions |
Compare expected vs actual |
If intentional product change, update expected values; otherwise flag for review |
| Timeout issues |
Add explicit waits |
Increase timeout thresholds, add expect with timeout, or use waitFor for async content |
| Missing elements |
Check feature status |
Determine if feature was removed/redesigned; flag for manual review or mark fixme |
| Network changes |
Update mocks/routes |
Update intercepted routes, mocks, or add retry logic for flaky endpoints |
See references/fix-strategies.md for detailed before/after examples.
Diagnosis Patterns
Use references/diagnosis-patterns.md for:
- Error message parsing — Extract selector, assertion, timeout from stack traces and failure output
- DOM comparison — Use browser snapshot to compare expected vs actual structure
- Network analysis — Inspect requests/responses when API or mock changes cause failures
MCP Integration
- Playwright MCP (cursor-ide-browser) — Run tests, navigate to failure state, take accessibility snapshots, inspect DOM, verify fixes
- Lock/unlock workflow — Lock browser before interactions; unlock when done
Scope
Can do (autonomous):
- Fix broken selectors by finding new locators via DOM inspection
- Update assertions when expected values have legitimately changed
- Add or adjust waits and timeouts for flaky/timeout failures
- Update network mocks, routes, or retry logic
- Mark unfixable tests as
test.fixme() with explanation
- Run tests in headed mode to reproduce and verify fixes
Cannot do (requires confirmation):
- Rewrite test logic or change test intent
- Add new test cases or modify test structure significantly
- Change production code
Will not do (out of scope):
- Modify production/application code
- Execute tests in CI without user request
- Approve or merge code changes
References
| Topic |
File |
| Detailed fix strategies with before/after examples |
references/fix-strategies.md |
| Error parsing, DOM comparison, network analysis |
references/diagnosis-patterns.md |
Quality Checklist
Troubleshooting
| Symptom |
Likely Cause |
Fix |
| Can't reproduce failure locally |
Environment difference, flaky test |
Run with --retries=0; check CI env vars; use same baseURL |
| Snapshot shows different structure |
Dynamic content, A/B test |
Wait for stable state; use more resilient locators |
| Fix works once then fails |
Race condition, shared state |
Add proper wait; ensure test isolation |
| Multiple failures in one file |
Cascading failure, setup issue |
Fix setup/fixture first; run tests individually |
| test.fixme() not recognized |
Framework difference |
Use test.skip() or equivalent for Cypress/pytest |
| MCP browser not available |
Playwright MCP not configured |
Use terminal to run tests; analyze error output only |
1---2name: qa-test-healer3description: Self-healing test system that runs failing tests, debugs with MCP tools, auto-fixes broken selectors/assertions/waits, and marks unfixable tests as test.fixme() with explanation.4---56# QA Test Healer78## Purpose910Automatically fix broken tests after code changes. Inspired by fugazi/test-automation-skills-agents, this skill runs failing tests in headed/debug mode, analyzes failures, applies targeted fixes, and either restores passing tests or marks unfixable cases as `test.fixme()` with a clear explanation.1112## Trigger Phrases1314- "Heal my failing tests"15- "Fix broken Playwright/Cypress tests"16- "Auto-fix test failures"17- "Tests are failing after my changes"18- "Debug and fix selector/assertion failures"19- "Run failing test and fix it"2021## Healing Workflow22231. **Receive failing test(s)** — User provides failing test path(s), error output, or CI failure logs242. **Run test in headed mode / with debug output** — Execute the test with visible browser and verbose logging to capture failure context253. **Analyze failure** — Determine root cause: selector broken? assertion changed? timeout? missing element? network change?264. **Apply fix strategy** — Use the appropriate strategy from `references/fix-strategies.md`275. **Re-run to verify fix** — Execute the test again; confirm it passes286. **If unfixable** — Mark as `test.fixme('explanation')` with a clear reason for manual review2930## Fix Strategies3132| Failure Type | Strategy | Action |33|--------------|----------|--------|34| **Broken selectors** | Find new locator | Use accessibility snapshot (Playwright MCP) to inspect DOM; update POM/test with stable locator (getByRole, getByTestId preferred) |35| **Changed assertions** | Compare expected vs actual | If intentional product change, update expected values; otherwise flag for review |36| **Timeout issues** | Add explicit waits | Increase timeout thresholds, add `expect` with timeout, or use `waitFor` for async content |37| **Missing elements** | Check feature status | Determine if feature was removed/redesigned; flag for manual review or mark fixme |38| **Network changes** | Update mocks/routes | Update intercepted routes, mocks, or add retry logic for flaky endpoints |3940See `references/fix-strategies.md` for detailed before/after examples.4142## Diagnosis Patterns4344Use `references/diagnosis-patterns.md` for:4546- **Error message parsing** — Extract selector, assertion, timeout from stack traces and failure output47- **DOM comparison** — Use browser snapshot to compare expected vs actual structure48- **Network analysis** — Inspect requests/responses when API or mock changes cause failures4950## MCP Integration5152- **Playwright MCP (cursor-ide-browser)** — Run tests, navigate to failure state, take accessibility snapshots, inspect DOM, verify fixes53- **Lock/unlock workflow** — Lock browser before interactions; unlock when done5455## Scope5657**Can do (autonomous):**58- Fix broken selectors by finding new locators via DOM inspection59- Update assertions when expected values have legitimately changed60- Add or adjust waits and timeouts for flaky/timeout failures61- Update network mocks, routes, or retry logic62- Mark unfixable tests as `test.fixme()` with explanation63- Run tests in headed mode to reproduce and verify fixes6465**Cannot do (requires confirmation):**66- Rewrite test logic or change test intent67- Add new test cases or modify test structure significantly68- Change production code6970**Will not do (out of scope):**71- Modify production/application code72- Execute tests in CI without user request73- Approve or merge code changes7475## References7677| Topic | File |78|-------|------|79| Detailed fix strategies with before/after examples | `references/fix-strategies.md` |80| Error parsing, DOM comparison, network analysis | `references/diagnosis-patterns.md` |8182## Quality Checklist8384- [ ] Root cause correctly identified before applying fix85- [ ] Fix strategy matches failure type per `references/fix-strategies.md`86- [ ] Test passes after fix (re-run verified)87- [ ] Unfixable tests marked with `test.fixme('clear explanation')`88- [ ] No production code modified89- [ ] POM updated if selector changed in shared locator90- [ ] Traceability preserved (test case IDs, comments)9192## Troubleshooting9394| Symptom | Likely Cause | Fix |95|---------|--------------|-----|96| Can't reproduce failure locally | Environment difference, flaky test | Run with `--retries=0`; check CI env vars; use same baseURL |97| Snapshot shows different structure | Dynamic content, A/B test | Wait for stable state; use more resilient locators |98| Fix works once then fails | Race condition, shared state | Add proper wait; ensure test isolation |99| Multiple failures in one file | Cascading failure, setup issue | Fix setup/fixture first; run tests individually |100| test.fixme() not recognized | Framework difference | Use `test.skip()` or equivalent for Cypress/pytest |101| MCP browser not available | Playwright MCP not configured | Use terminal to run tests; analyze error output only |