rtk icon indicating copy to clipboard operation
rtk copied to clipboard

rtk playwright test drops the flaky result: a retried test renders as PASS (0) FAIL (0)

Open zhanghao87 opened this issue 2 weeks ago • 1 comments

Summary

rtk playwright test drops the flaky result. A test that fails on the first attempt and passes on a retry is reported by Playwright as 1 flaky; rtk's summary reports PASS (0) FAIL (0) and the process still exits 0. The compressed output therefore says "nothing ran, nothing failed" for a run that actually executed one test and retried it.

Environment

  • rtk 1.2.0 (Homebrew formula rtk-oss), aarch64-apple-darwin
  • @playwright/test 1.59.1, Node v24.11.1, macOS
  • The command reaches rtk through a hook: rtk rewrite "npx playwright test <file> --workers=1 --retries=1" returns rtk playwright test <file> --workers=1 --retries=1

Reproduction

One spec that fails on the first attempt and passes on the retry:

// tests/e2e/zz-flaky.spec.ts
import { test, expect } from '@playwright/test';
import { existsSync, writeFileSync } from 'fs';

const flag = '/tmp/rtk-flaky-flag';

test('flaky on first attempt', async () => {
  if (!existsSync(flag)) {
    writeFileSync(flag, '1');
    throw new Error('intentional first-attempt failure');
  }
  expect(true).toBe(true);
});
rm -f /tmp/rtk-flaky-flag
npx playwright test tests/e2e/zz-flaky.spec.ts --workers=1 --retries=1

Raw Playwright (exit 0):

  1 flaky
    [chromium] › tests/e2e/zz-flaky.spec.ts:4:1 › flaky on first attempt ──────────────────────

rtk playwright test tests/e2e/zz-flaky.spec.ts --workers=1 --retries=1 (exit 0):

PASS (0) FAIL (0)

Time: 970ms

The test ran, failed, and was retried into a pass. rtk reports zero passed and zero failed, drops the 1 flaky marker, and keeps the green exit code.

Why this one is worse than the suite-level cases

In #3588 (jest) and #3935 (vitest) the summary is false but the exit code is non-zero, so a caller that trusts the exit code still sees the failure — and the summary is false in a way that a careful reader can flag.

Here both the summary and the exit code are green. Nothing in the compressed output distinguishes a flaky run from a clean one, and unlike the failing runs this output carries no [full output: rtk recall <hash>] hint, so the raw output is not recoverable through the recall store either. The only trace of the first-attempt failure is left in Playwright's own artifacts (test-results/.../error-context.md).

--retries=0 turns the flaky test into a hard failure and hides the problem, so the defect only shows up in runs that allow retries (retries: process.env.CI ? 2 : 0 in a typical playwright.config.ts).

Expected

Either the summary keeps the flaky count, for example:

PASS (1) FAIL (0) FLAKY (1)

or the filter falls back to raw output when the result contains a retried/flaky test — the behaviour PR #4515 describes for the JSON path.

Workaround

Run with --retries=0 so a flaky test becomes a hard failure, or treat a summary with zero passed tests as "inspect the raw output".

zhanghao87 avatar Nov 17 '26 03:11 zhanghao87

wshm · Automated triage by AI

🔍 Automated Triage

🐛 Category bug
🟠 Priority high
🎯 Confidence 94%

Summary

rtk playwright summary filter drops flaky/retried test results, reporting PASS(0) FAIL(0) with exit 0 instead of surfacing the retry and failure.

📁 Relevant files
  • src/filters/playwright.rs

Suggested Actions

  1. Extend playwright filter to parse Playwright's 'N flaky' summary line and surface FLAKY count
  2. Fall back to raw output (with recall hint) when a flaky/retried test is detected, per PR #4515's JSON-path behavior
  3. Compare with #3588 and #3935 (jest/vitest flaky summary mishandling) for shared fix pattern
  4. Add regression test using --retries=1 with a first-fail-then-pass spec like the repro in this issue

Triaged automatically by wshm · This is an automated analysis, not a human review.

rtk-wshm-sync-bot avatar Nov 17 '26 03:11 rtk-wshm-sync-bot