Skip to content

Commit fbae730

Browse files
committed
feat(cli): add 'test flaky' repeat-run flaky-test detector
1 parent 18f6e6e commit fbae730

8 files changed

Lines changed: 869 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to `@testsprite/testsprite-cli` are documented here. The for
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- **`testsprite test flaky <test-id>`** — repeat-run flaky-test detector. Replays a test N times (`--runs <n>`, default 5), aggregates the outcomes, and reports a stability verdict (`stable` / `flaky` / `failing`) plus the `runId` and `failureKind` of every attempt that did not pass. Replays run with auto-heal OFF (strict verbatim) so a healed drift can't mask a nondeterministic pass/fail. Exit code is 0 only when every attempt passed, so CI can gate a merge on flakiness (`testsprite test flaky <id> --runs 5 || exit 1`). Flags: `--runs <n>` (1–100), `--until-fail` (stop at the first non-passing attempt), `--timeout <s>` (per-attempt), and `--output json` for a machine-readable stability report. Frontend replays are free verbatim script replays; a one-line advisory is printed for backend tests, whose closure reruns may cost credits.
10+
711
## [0.1.2] - 2026-06-19
812

913
### Added

DOCUMENTATION.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,29 @@ Flags:
380380

381381
A batch rerun returns `accepted[]` (one `runId` per dispatched test) plus `deferred[]` for any test shed by the per-key run-rate limit; under `--wait`, a non-empty `deferred[]` exits 7 with a `nextAction` you can retry with a fresh idempotency key.
382382

383+
#### `testsprite test flaky <test-id>`
384+
385+
Detect a **flaky** test by replaying it several times and reporting how often it passes. Each attempt is a rerun with auto-heal **off** (a strict verbatim replay), so healed drift can't disguise a nondeterministic pass/fail — this measures the replay stability of the saved script against the configured URL. Frontend replays are free verbatim script replays; backend tests re-run their dependency closure and may cost credits (a one-line stderr advisory is printed before the run).
386+
387+
```bash
388+
# Replay 10 times and print a stability score
389+
testsprite test flaky test_xxxxxxxx --runs 10
390+
391+
# Fast "is it flaky at all?" — stop at the first non-passing attempt
392+
testsprite test flaky test_xxxxxxxx --runs 20 --until-fail
393+
394+
# Machine-readable stability report for CI
395+
testsprite test flaky test_xxxxxxxx --runs 10 --output json
396+
```
397+
398+
Flags:
399+
400+
- `--runs <n>` — number of replays (1–100, default 5).
401+
- `--until-fail` — stop at the first attempt that does not pass.
402+
- `--timeout <s>` — per-attempt polling deadline (same semantics as `test wait`).
403+
404+
`--output json` emits `{ testId, runs, passed, failed, stableRatio, verdict, failures: [{ attempt, runId, outcome, failureKind }] }`. Exit codes: **0** when every observed attempt passed (`stable`); **1** when any attempt did not pass (`flaky` or `failing`); **4** when the test has no replayable run (trigger `testsprite test run <id>` first); **5** on a validation error.
405+
383406
#### `testsprite test wait <run-id>`
384407

385408
Block until a run reaches a terminal status. Same exit-code matrix as `test run --wait`. Used to resume polling after a timed-out `test run --wait`, or when an agent already has a `runId` from a previous invocation.

0 commit comments

Comments
 (0)