Skill Details
Runtime
(claude-5-5-sonnet)
Example user message
[userMessage]: This test passes on my MacBook 90% of the time but fails randomly in GitHub Actions CI. Fix it properly: `let createdId: string; test('creates and displays invoice', async () => { const res = await api.post('/invoices', { amount: 5000 }); createdId = res.data.id; await page.goto('/invoices'); await page.waitForTimeout(300); expect(await page.textContent('.invoice-row:first-child')).toContain(createdId); });`
Example agent response
## 🩺 Flaky Test Diagnosis: F1 (Async Race) + F2 (Shared Order-Dependent State) (Confidence: Medium — both triggers visible in the snippet; CI log not attached)
- **Target**: `creates and displays invoice`
- **Likely Failure Mechanism**: A fixed 300ms sleep can race CI API/render latency, and `.invoice-row:first-child` assumes no parallel worker inserted a newer invoice.
- **What would confirm it**: a CI log showing the assertion read an empty or stale table, plus the test passing reliably with `--workers=1`.
### 1. Evidence
- `.invoice-row:first-child` depends on global row order: another worker invoice can land above yours.
- `waitForTimeout(300)` reads the DOM before the table hydrates on a loaded CI runner.
### 2. Candidate Fix (No Sleeps / No Blind Retries)
```diff
- let createdId: string;
- await page.waitForTimeout(300);
- expect(await page.textContent('.invoice-row:first-child')).toContain(createdId);
+ const createdId = res.data.id;
+ const row = page.getByTestId(`invoice-row-${createdId}`);
+ await expect(row).toBeVisible();
+ await expect(row).toContainText('5000');
```
### 3. Repetition Check (run it yourself)
```bash
npx playwright test invoices.spec.ts --repeat-each=20 --workers=4
```
- 20 clean runs is useful evidence; it does not rule out another class.
### 4. Open Risks
- Create the invoice with a unique reference and clean it up in `afterEach`, so pagination cannot push the new row onto page 2.
By purchasing this skill, you agree to our terms of service
CLAUDE-5-5-SONNET
Flaky tests hide bugs and erode trust in CI. Paste test code or a CI log and the skill classifies the likely cause from a 7-class matrix (async race, shared state, clock/timezone, randomness, port collision, live network, brittle selector), flags the unstable lines, proposes a candidate patch without sleep() padding, blind retries or silent skips, and gives a repeat-run command to check the flake again. For Jest, Vitest, Playwright, Pytest, Go, JUnit. Diagnoses are hypotheses, not promises.
...more
Added 1 hour ago
