flakefinder 0.0.0-stage → 1.2.1
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 +217 -2
- package/dist/cli.js +7286 -0
- package/package.json +70 -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,218 @@
|
|
|
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. Same-commit flips
|
|
37
|
+
(a failure and a pass on one commit), 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 a failure and a pass on the same code state |
|
|
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 five observed runs all failed, or all available runs if fewer than five, with at least `minRuns` |
|
|
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
|
+
Configure your test runner to emit a machine-readable report using the
|
|
60
|
+
table below. For example, with Jest:
|
|
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 reports the recovered test and the remaining failure …
|
|
79
|
+
… the command exits with status 1 …
|
|
80
|
+
|
|
81
|
+
$ npx flakefinder report # terminal table from accumulated history
|
|
82
|
+
$ npx flakefinder report --flakes-only --no-color # CI-friendly, problems only
|
|
83
|
+
$ npx flakefinder html # writes flakefinder-report.html — open it
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The excerpt illustrates the Jest fixture in `fixtures/jest-project`. Its
|
|
87
|
+
`flaky-counter` fails on odd invocations, and `always-fail` fails every time.
|
|
88
|
+
|
|
89
|
+
## Supported report formats
|
|
90
|
+
|
|
91
|
+
| Format | Runners | How to make your runner emit it |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| 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' }]]` |
|
|
94
|
+
| Jest-compatible JSON | Jest, Vitest | Jest `jest --json --outputFile=jest.json` or Vitest `vitest run --reporter=json --outputFile=jest.json` |
|
|
95
|
+
| Mocha JSON | Mocha, mocha-wrapper runners | `mocha --reporter json --reporter-options output=test-results/report.json` |
|
|
96
|
+
| go test -json | Go | `go test -json ./... > test-output.jsonl` (add `-count=1` to defeat Go's result cache) |
|
|
97
|
+
| TAP | node:test (`--test-reporter=tap`), TAP14 producers | `node --test --test-reporter=tap > tap.txt` |
|
|
98
|
+
| TRX | .NET (`dotnet test`), VSTest | `dotnet test --logger "trx;LogFileName=results.trx"` |
|
|
99
|
+
| Playwright JSON | Playwright (per-attempt retries) | `npx playwright test --reporter=json > pw.json` |
|
|
100
|
+
| pytest-json-report | pytest with the `pytest-json-report` plugin | `pytest --json-report --json-report-file=report.json` |
|
|
101
|
+
|
|
102
|
+
Reports may be UTF-8 or UTF-16 (e.g. PowerShell `>` output) and may be gzip-compressed.
|
|
103
|
+
|
|
104
|
+
The parser is auto-detected per file from its content, so mixed reports in one
|
|
105
|
+
repo are fine. Point `flakefinder.config.json` → `reports` globs at them.
|
|
106
|
+
|
|
107
|
+
## GitHub Action
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
- run: npm test # your tests write report files
|
|
111
|
+
- name: flakefinder
|
|
112
|
+
uses: DJJW26/flakefinder@024fccee61b5ac58e18adf35e2739c7231192e64 # v1.2.0
|
|
113
|
+
if: always()
|
|
114
|
+
with:
|
|
115
|
+
fail-on-new-flakes: 'false'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The action caches `.flakefinder/` between runs (history-aware verdicts),
|
|
119
|
+
comments on PRs with **new vs known** flakes, uploads the HTML dashboard as an
|
|
120
|
+
artifact, and can fail the job when *new* flakes appear. Matrix legs keep
|
|
121
|
+
separate histories automatically. Full input/output reference, matrix and
|
|
122
|
+
monorepo recipes: [docs/github-action.md](docs/github-action.md).
|
|
123
|
+
|
|
124
|
+
Start with reporting and review the results from your own suite before
|
|
125
|
+
enabling `fail-on-new-flakes`. The example pins the commit tagged `v1.2.0`.
|
|
126
|
+
|
|
127
|
+
## Quarantine
|
|
128
|
+
|
|
129
|
+
Replace `YOUR_TEST_ID` with the ID from `flakefinder report --format json`.
|
|
130
|
+
|
|
131
|
+
```console
|
|
132
|
+
$ npx flakefinder quarantine add YOUR_TEST_ID --reason "order-dependent"
|
|
133
|
+
$ npx flakefinder quarantine list
|
|
134
|
+
$ npx flakefinder run -- npm test # supported runners exclude the quarantined tests
|
|
135
|
+
$ npx flakefinder quarantine remove YOUR_TEST_ID
|
|
136
|
+
$ npx flakefinder quarantine prune # releases entries with positive evidence of health
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Exclusion is done with runner flags — `pytest --deselect`, `jest -t`,
|
|
140
|
+
`mocha --grep` — computed from the quarantine list at run time. flakefinder
|
|
141
|
+
**never edits your test files**; remove the entry and the test is back.
|
|
142
|
+
Package-manager wrappers forward the flags using the package manager's
|
|
143
|
+
argument rules. For example, npm uses `--` and pnpm forwards the flags directly. For `go` there is no per-test exclusion flag: entries are
|
|
144
|
+
tracked and reported, but not auto-excluded.
|
|
145
|
+
|
|
146
|
+
## Design principles
|
|
147
|
+
|
|
148
|
+
- **Local-first.** The CLI keeps test history on disk. The optional GitHub
|
|
149
|
+
Action uses GitHub for caching, dashboard artifacts, and PR comments.
|
|
150
|
+
- **Small CLI.** A single entry file with two direct runtime dependencies
|
|
151
|
+
(`commander` and `fast-xml-parser`), installed by npm.
|
|
152
|
+
- **Exit codes you can script.** For `run`, `0` means clean or retry-rescued
|
|
153
|
+
tests only, `1` means a failure persisted, and `2` means a usage or
|
|
154
|
+
environment error.
|
|
155
|
+
- **Deterministic.** Classification, scores, and confidence are transparent
|
|
156
|
+
rules over your history — no AI, no randomness, same input → same verdict.
|
|
157
|
+
|
|
158
|
+
## FAQ
|
|
159
|
+
|
|
160
|
+
**How much overhead does `run` add?**
|
|
161
|
+
Retries run only after a failed attempt. By default, supported runners retry
|
|
162
|
+
just the failed tests when the reports identify them. Other retries rerun the
|
|
163
|
+
full command. A green suite runs once. Set the retry limit with `-R` or `liveRetries`, or ingest reports
|
|
164
|
+
directly to skip live retries.
|
|
165
|
+
|
|
166
|
+
**What happens when tests get renamed?**
|
|
167
|
+
A rename starts a new history. See the usage guide for file and report scopes
|
|
168
|
+
available in `1.2.1` and later. [Test identity](docs/USAGE.md#test-identity)
|
|
169
|
+
|
|
170
|
+
**Monorepo support?**
|
|
171
|
+
Yes — run each package with `--cwd <dir>` (config, reports, and store resolve
|
|
172
|
+
relative to it), or use the Action's `working-directory` input. Each package
|
|
173
|
+
keeps its own history store.
|
|
174
|
+
|
|
175
|
+
**Does it modify my tests or my runner config?**
|
|
176
|
+
`init` creates `flakefinder.config.json`. `run` invokes your command, reads its
|
|
177
|
+
reports, and saves history. Quarantine applies runner filters. Configure your
|
|
178
|
+
test runner to write reports using the supported formats above.
|
|
179
|
+
|
|
180
|
+
**Where does my data live, and who can see it?**
|
|
181
|
+
By default the CLI writes `.flakefinder/history.jsonl` under the working
|
|
182
|
+
directory. Multiple records can belong to one run. The Action stores history
|
|
183
|
+
in GitHub Actions cache and can publish PR comments and a dashboard artifact.
|
|
184
|
+
With GitLab credentials configured, `flakefinder ci` can post an MR note.
|
|
185
|
+
See the [privacy details](docs/USAGE.md#privacy).
|
|
186
|
+
|
|
187
|
+
**Does it work with runner X?**
|
|
188
|
+
If X can emit JUnit XML, Jest JSON, Mocha JSON, `go test -json`, TAP, TRX,
|
|
189
|
+
Playwright JSON, or pytest-json-report,
|
|
190
|
+
yes — that covers most of the ecosystem.
|
|
191
|
+
|
|
192
|
+
## Development
|
|
193
|
+
|
|
194
|
+
```console
|
|
195
|
+
$ npm ci && npm run build # build the CLI and Action bundles
|
|
196
|
+
$ npm test # unit tests
|
|
197
|
+
$ npm run e2e # real jest/pytest/go fixtures, end to end
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The fixtures under `fixtures/` are three real mini-projects (Jest, pytest, Go)
|
|
201
|
+
with a deterministic file-counter flake — the e2e harness proves the whole
|
|
202
|
+
pipeline: run → retries → classify → report → dashboard → quarantine.
|
|
203
|
+
|
|
204
|
+
## Project documentation
|
|
205
|
+
|
|
206
|
+
- [Usage guide](docs/USAGE.md) for CLI commands, configuration, and report formats.
|
|
207
|
+
- [Technical guide](docs/EXPLAINER.md) for architecture and scoring.
|
|
208
|
+
- [Project context](docs/PROJECT_CONTEXT.md) for the codebase and build map.
|
|
209
|
+
- [Release runbook](docs/RELEASING.md) for preparing releases and verifying Windows, Ubuntu, and macOS builds.
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
Issues and PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
[MIT](LICENSE). The GitHub Action bundle includes third-party packages; their
|
|
218
|
+
licenses are listed in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|