flakefinder 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +242 -2
- package/dist/cli.js +6816 -0
- package/package.json +64 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 flakefinder contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,243 @@
|
|
|
1
|
-
#
|
|
1
|
+
# flakefinder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Find flaky tests locally and track them in CI.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/DJJW26/flakefinder/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/flakefinder)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](package.json)
|
|
9
|
+
|
|
10
|
+
flakefinder wraps your existing test command and shows which tests passed on
|
|
11
|
+
retry and which failures persisted. In CI, it reads the reports your tests
|
|
12
|
+
already produce and builds a history you can review in the terminal, an HTML
|
|
13
|
+
dashboard, or GitHub pull requests.
|
|
14
|
+
|
|
15
|
+
## Who it’s for
|
|
16
|
+
|
|
17
|
+
If your team regularly reruns red builds, flakefinder can show which tests
|
|
18
|
+
repeatedly cost you time. It accepts mixed report formats, including Playwright
|
|
19
|
+
JSON, pytest reports, and Go test output, so you can use it across a repo with
|
|
20
|
+
multiple test runners. The CLI stores history locally and requires no hosted
|
|
21
|
+
account or separate service.
|
|
22
|
+
|
|
23
|
+
## How it works
|
|
24
|
+
|
|
25
|
+
Two modes, one history store.
|
|
26
|
+
|
|
27
|
+
**INSTANT — `flakefinder run -- <command>`**
|
|
28
|
+
Wraps your command and re-runs it when it fails (up to `--retries` extra
|
|
29
|
+
attempts). A test that fails on attempt 1 and passes on attempt 2 of the same
|
|
30
|
+
invocation was *rescued by a retry*. A test that still fails on the final
|
|
31
|
+
attempt is reported as a persistent failure. The exit code lets CI distinguish
|
|
32
|
+
a run with only retry-rescued tests from one with failures still present.
|
|
33
|
+
|
|
34
|
+
**HISTORY — `flakefinder ingest` / `report` / `html`**
|
|
35
|
+
Every parsed run lands in an append-only JSONL store (`.flakefinder/history.jsonl`).
|
|
36
|
+
The engine replays each test's timeline and classifies it: same-commit flips
|
|
37
|
+
(failed *and* passed on one commit — the strongest possible signal), retry
|
|
38
|
+
rescues, and flip-flop patterns across commits (or across runs, when no git
|
|
39
|
+
metadata exists) each count toward a 0–100 flake score with a confidence
|
|
40
|
+
value. Weeks of CI runs turn into a ranked list of worst offenders.
|
|
41
|
+
|
|
42
|
+
### Classification
|
|
43
|
+
|
|
44
|
+
| Verdict | Meaning |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `FLAKY (confirmed)` | observed both a failure and a pass on the same commit |
|
|
47
|
+
| `FLAKY (retry-rescued)` | failed, then passed on a retry of the same run |
|
|
48
|
+
| `FLAKY (suspected)` | result flipped ≥ 2 times across commits/runs; score-gated |
|
|
49
|
+
| `FAILING` | last 5 observations all failed |
|
|
50
|
+
| `NEW FAILURE` | failed on the latest run, not enough data yet to say more |
|
|
51
|
+
| passing / skipped / gone | healthy, always-skipped, not seen in 30 runs |
|
|
52
|
+
|
|
53
|
+
Tags: `slow` (median over `slowThresholdMs`, or p95 far above the suite
|
|
54
|
+
median), `recently-fixed` (failed historically, stably passing now),
|
|
55
|
+
`long-unseen`.
|
|
56
|
+
|
|
57
|
+
## Quickstart
|
|
58
|
+
|
|
59
|
+
Your test runner must emit a machine-readable report (one flag — see the
|
|
60
|
+
table below). Then:
|
|
61
|
+
|
|
62
|
+
```console
|
|
63
|
+
$ npx flakefinder init
|
|
64
|
+
created flakefinder.config.json (runner: jest)
|
|
65
|
+
|
|
66
|
+
next step — make your runner emit machine-readable reports:
|
|
67
|
+
jest: add the jest-junit reporter (npm i -D jest-junit), jest.config:
|
|
68
|
+
reporters: ['default', ['jest-junit', { outputDirectory: '.', outputName: 'junit.xml' }]]
|
|
69
|
+
|
|
70
|
+
$ npx flakefinder run -- npm test
|
|
71
|
+
flakefinder: attempt 1/3 → npm test
|
|
72
|
+
… your normal test output — attempt 1 fails …
|
|
73
|
+
flakefinder: attempt 2/3 → npm test
|
|
74
|
+
… the flaky test passes this time; the other test still fails …
|
|
75
|
+
flakefinder: attempt 3/3 → npm test
|
|
76
|
+
… the other test still fails on the final attempt …
|
|
77
|
+
|
|
78
|
+
flakefinder — 5 tracked test(s), 2 need attention
|
|
79
|
+
|
|
80
|
+
FLAKY (confirmed) — 1
|
|
81
|
+
90 conf 100% runs 3 pass 33% med 1ms flaky-counter fails on odd counts :: flaky-counter fails on odd counts
|
|
82
|
+
|
|
83
|
+
FAILING — 1
|
|
84
|
+
0 conf 40% runs 3 pass 0% med 2ms always-fail fails deterministically :: always-fail fails deterministically
|
|
85
|
+
|
|
86
|
+
ok: 3 passing · 0 skipped · 0 gone from recent runs
|
|
87
|
+
|
|
88
|
+
next steps:
|
|
89
|
+
• quarantine the worst offender:
|
|
90
|
+
flakefinder quarantine add b6930d21e68e49f7
|
|
91
|
+
• full interactive report: flakefinder html
|
|
92
|
+
|
|
93
|
+
$ echo $?
|
|
94
|
+
1 # a failure persisted through the final attempt
|
|
95
|
+
|
|
96
|
+
$ npx flakefinder report # terminal table from accumulated history
|
|
97
|
+
$ npx flakefinder report --flakes-only --no-color # CI-friendly, problems only
|
|
98
|
+
$ npx flakefinder html # writes flakefinder-report.html — open it
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
<!-- TODO: screenshot: terminal report -->
|
|
102
|
+
|
|
103
|
+
The sample above is the real output of this repo's jest fixture
|
|
104
|
+
(`fixtures/jest-project`), where `flaky-counter` fails on odd invocations by
|
|
105
|
+
design and `always-fail` never passes.
|
|
106
|
+
|
|
107
|
+
<!-- TODO: screenshot: dashboard -->
|
|
108
|
+
|
|
109
|
+
## Supported report formats
|
|
110
|
+
|
|
111
|
+
| Format | Runners | How to make your runner emit it |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| JUnit XML | pytest, Jest (jest-junit), vitest (junit reporter), Maven/surefire, anything JUnit-shaped | pytest: `--junitxml=junit.xml` · jest: `reporters: ['default', ['jest-junit', { outputDirectory: '.', outputName: 'junit.xml' }]]` |
|
|
114
|
+
| Jest JSON | Jest, vitest (`--json` stream) | `jest --json --outputFile=jest.json` (flakefinder also accepts jest-junit XML) |
|
|
115
|
+
| Mocha JSON | Mocha, mocha-wrapper runners | `mocha --reporter json --reporter-options output=test-results/report.json` |
|
|
116
|
+
| go test -json | Go | `go test -json ./... > test-output.jsonl` (add `-count=1` to defeat Go's result cache) |
|
|
117
|
+
| TAP | node:test (`--test-reporter=tap`), TAP14 producers | `node --test --test-reporter=tap > tap.txt` |
|
|
118
|
+
| TRX | .NET (`dotnet test`), VSTest | `dotnet test --logger "trx;LogFileName=results.trx"` |
|
|
119
|
+
| Playwright JSON | Playwright (per-attempt retries) | `PLAYWRIGHT_JSON_OUTPUT_NAME=pw.json npx playwright test --reporter=json` |
|
|
120
|
+
| pytest-json-report | pytest with the `pytest-json-report` plugin | `pytest --json-report --json-report-file=report.json` |
|
|
121
|
+
|
|
122
|
+
Reports may be UTF-8 or UTF-16 (e.g. PowerShell `>` output) and may be gzip-compressed.
|
|
123
|
+
|
|
124
|
+
The parser is auto-detected per file from its content, so mixed reports in one
|
|
125
|
+
repo are fine. Point `flakefinder.config.json` → `reports` globs at them.
|
|
126
|
+
|
|
127
|
+
## GitHub Action
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
- run: npm test # your tests write report files
|
|
131
|
+
- name: flakefinder
|
|
132
|
+
uses: DJJW26/flakefinder@f1bc4dd92ad2a11ac49d74d7ac272f9f25e11d7f
|
|
133
|
+
if: always()
|
|
134
|
+
with:
|
|
135
|
+
fail-on-new-flakes: 'false'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The action caches `.flakefinder/` between runs (history-aware verdicts),
|
|
139
|
+
comments on PRs with **new vs known** flakes, uploads the HTML dashboard as an
|
|
140
|
+
artifact, and can fail the job when *new* flakes appear. Matrix legs keep
|
|
141
|
+
separate histories automatically. Full input/output reference, matrix and
|
|
142
|
+
monorepo recipes: [docs/github-action.md](docs/github-action.md).
|
|
143
|
+
|
|
144
|
+
Start with reporting and review the results from your own suite before
|
|
145
|
+
enabling `fail-on-new-flakes`. The example pins a full commit SHA from `main`
|
|
146
|
+
so each workflow run uses the same Action code.
|
|
147
|
+
|
|
148
|
+
## Quarantine
|
|
149
|
+
|
|
150
|
+
```console
|
|
151
|
+
$ npx flakefinder quarantine add b6930d21e68e49f7 --reason "order-dependent"
|
|
152
|
+
quarantined flaky-counter fails on odd counts :: flaky-counter fails on odd counts (flaky-confirmed, score 90)
|
|
153
|
+
|
|
154
|
+
$ npx flakefinder quarantine list
|
|
155
|
+
1 quarantined test(s):
|
|
156
|
+
b6930d21e68e49f7 flaky-counter fails on odd counts :: flaky-counter fails on odd counts (score 90, order-dependent)
|
|
157
|
+
next run will add: -t ^(?!.*(?:flaky-counter fails on odd counts))
|
|
158
|
+
|
|
159
|
+
$ npx flakefinder run -- npm test # quarantined tests are now excluded
|
|
160
|
+
$ npx flakefinder quarantine remove b6930d21e68e49f7
|
|
161
|
+
$ npx flakefinder quarantine prune # releases entries with positive evidence of health
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Exclusion is done with runner flags — `pytest --deselect`, `jest -t`,
|
|
165
|
+
`mocha --grep` — computed from the quarantine list at run time. flakefinder
|
|
166
|
+
**never edits your test files**; remove the entry and the test is back.
|
|
167
|
+
Package-manager wrappers forward the flags using the package manager's
|
|
168
|
+
argument rules. For example, npm uses `--` and pnpm forwards the flags directly. For `go` there is no per-test exclusion flag: entries are
|
|
169
|
+
tracked and reported, but not auto-excluded.
|
|
170
|
+
|
|
171
|
+
## Design principles
|
|
172
|
+
|
|
173
|
+
- **Local-first.** The CLI keeps test history on disk. The optional GitHub
|
|
174
|
+
Action uses GitHub for caching, dashboard artifacts, and PR comments.
|
|
175
|
+
- **Small CLI.** A single entry file with two direct runtime dependencies
|
|
176
|
+
(`commander` and `fast-xml-parser`), installed by npm.
|
|
177
|
+
- **Exit codes you can script.** For `run`, `0` means clean or retry-rescued
|
|
178
|
+
tests only, `1` means a failure persisted, and `2` means a usage or
|
|
179
|
+
environment error.
|
|
180
|
+
- **Deterministic.** Classification, scores, and confidence are transparent
|
|
181
|
+
rules over your history — no AI, no randomness, same input → same verdict.
|
|
182
|
+
|
|
183
|
+
## FAQ
|
|
184
|
+
|
|
185
|
+
**How much overhead does `run` add?**
|
|
186
|
+
Retries run only after a failed attempt. By default, supported runners retry
|
|
187
|
+
just the failed tests and other runners retry the full command. A green suite
|
|
188
|
+
runs once. Set the retry limit with `-R` or `liveRetries`, or ingest reports
|
|
189
|
+
directly to skip live retries.
|
|
190
|
+
|
|
191
|
+
**What happens when tests get renamed?**
|
|
192
|
+
Identity is `sha256(suite + name)`, so a rename forks history: the old test
|
|
193
|
+
goes `gone`, the new one starts fresh. Live with it by renaming deliberately
|
|
194
|
+
(fresh history is honest), or keep names stable and change the *assertions*.
|
|
195
|
+
|
|
196
|
+
**Monorepo support?**
|
|
197
|
+
Yes — run each package with `--cwd <dir>` (config, reports, and store resolve
|
|
198
|
+
relative to it), or use the Action's `working-directory` input. Each package
|
|
199
|
+
keeps its own history store.
|
|
200
|
+
|
|
201
|
+
**Does it modify my tests or my runner config?**
|
|
202
|
+
No. `init` writes one new file (`flakefinder.config.json`), `run` only reads
|
|
203
|
+
report files your runner writes, and quarantine works by appending runner
|
|
204
|
+
flags — never by editing sources. The one thing you must do yourself is turn
|
|
205
|
+
on machine-readable reports (one flag, shown in the table above).
|
|
206
|
+
|
|
207
|
+
**Where does my data live, and who can see it?**
|
|
208
|
+
`.flakefinder/history.jsonl` next to your config — plain JSON Lines, one run
|
|
209
|
+
per line. `cat` it, grep it, delete it, gitignore it (init reminders do).
|
|
210
|
+
Nothing is uploaded anywhere unless you use the GitHub Action, in which case
|
|
211
|
+
history lives in your repository's actions cache.
|
|
212
|
+
|
|
213
|
+
**Does it work with runner X?**
|
|
214
|
+
If X can emit JUnit XML, Jest JSON, Mocha JSON, `go test -json`, TAP, TRX,
|
|
215
|
+
Playwright JSON, or pytest-json-report,
|
|
216
|
+
yes — that covers most of the ecosystem.
|
|
217
|
+
|
|
218
|
+
## Development
|
|
219
|
+
|
|
220
|
+
```console
|
|
221
|
+
$ npm ci && npm run build # build the CLI and Action bundles
|
|
222
|
+
$ npm test # unit tests
|
|
223
|
+
$ npm run e2e # real jest/pytest/go fixtures, end to end
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
The fixtures under `fixtures/` are three real mini-projects (Jest, pytest, Go)
|
|
227
|
+
with a deterministic file-counter flake — the e2e harness proves the whole
|
|
228
|
+
pipeline: run → retries → classify → report → dashboard → quarantine.
|
|
229
|
+
|
|
230
|
+
## Project documentation
|
|
231
|
+
|
|
232
|
+
- [Usage guide](docs/USAGE.md) for CLI commands, configuration, and report formats.
|
|
233
|
+
- [Project context](docs/PROJECT_CONTEXT.md) for the codebase and build map.
|
|
234
|
+
- [Release runbook](docs/RELEASING.md) for preparing releases and verifying Windows, Ubuntu, and macOS builds.
|
|
235
|
+
|
|
236
|
+
## Contributing
|
|
237
|
+
|
|
238
|
+
Issues and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
[MIT](LICENSE). The GitHub Action bundle includes third-party packages; their
|
|
243
|
+
licenses are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|