Flaky Test Detection
Task → Which mode?
├─ Reviewing changed test files / PR diff for risk patterns → Review mode
├─ Fixing a known flaky Jest unit test → Review mode + local reproduce loop
└─ Auditing CI history to rank flaky tests by failure rate → open references/gh-analysis.md
Constraints
All proposed fixes must comply with mms-mobile-testing (unit path) and mms-coding-guidelines. Key rules:
- Use
jest.mocked(fn)— neverfn as jest.Mock - Use
toBeOnTheScreen()— nevertoBeTruthy()/toBeDefined()for element presence - Use
yarncommands — never npm or npx - No
toMatchSnapshot()— use explicit assertions ortoMatchInlineSnapshot()
Review mode
- Scan changed
.test.ts(x)files against the pattern table (J1–J10). - Classify each hit (async / timing / isolation / mock / state).
- Propose the fix for each hit using the ✅ pattern from the matching section — apply only on explicit confirmation.
- Run the local reproduction loop to confirm the fix holds.
Audit mode
Query GitHub Actions run history to produce a ranked list of historically flaky unit test files with failure rates and suggested fix categories.
Open references/gh-analysis.md for the full procedure.