You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e363396
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat: --last-failed option for run and run-workers (#5733)
* feat: add --last-failed option to run and run-workers
Every run and run-workers now saves result.json to the output dir via
Result.save(). --last-failed reads it and runs only tests whose state is
failed, matched by test uid, filtering before tests are split into workers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: use Object type in filterLastFailedTests JSDoc for typings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* keep result.json on empty runs, record tests of suites with failed BeforeSuite
* ifx
* fix
---------
Co-authored-by: DavertMik <davert@testomat.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Denys Kuchma <den.kuchma@ukr.net>
Copy file name to clipboardExpand all lines: docs/commands.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,14 @@ Run test files in shuffled order
53
53
npx codeceptjs run --shuffle
54
54
```
55
55
56
+
Rerun only tests that failed in the previous run
57
+
58
+
```sh
59
+
npx codeceptjs run --last-failed
60
+
```
61
+
62
+
See [Last Failed](#last-failed) for details.
63
+
56
64
Run single test in debug mode (see more in [debugging](#Debugging) section)
57
65
58
66
```sh
@@ -158,6 +166,9 @@ npx codeceptjs run-workers 3 --by suite
158
166
# Pool mode with filtering
159
167
npx codeceptjs run-workers 4 --by pool --grep "@smoke"
160
168
169
+
# Rerun only tests that failed in the previous run
170
+
npx codeceptjs run-workers 3 --last-failed
171
+
161
172
# Run tests tagged @serial one by one after parallel workers finish
162
173
npx codeceptjs run-workers 3 --serial "@serial"
163
174
```
@@ -174,6 +185,25 @@ The pool mode provides the best load balancing by maintaining tests in a shared
174
185
175
186
See [Parallel Execution](/parallel) documentation for more details.
176
187
188
+
## Last Failed
189
+
190
+
Rerun only the tests that failed in the previous run. Works with `run` and `run-workers`, including all `--by` strategies:
191
+
192
+
```sh
193
+
npx codeceptjs run --last-failed
194
+
npx codeceptjs run-workers 3 --last-failed
195
+
```
196
+
197
+
Every `run` and `run-workers` writes a report to `result.json` in the output directory (`output` in config). It lists each executed test with its state. `--last-failed` reads this report and runs only the tests whose state is `failed`:
198
+
199
+
- Skipped and pending tests are not considered failed.
200
+
- Tests are matched by their title, including the Feature title. A renamed test or Feature is not matched.
201
+
- Combined with `--grep`, only failed tests that also match the pattern are run.
202
+
- The report always reflects the most recent run, including a `--last-failed` run. Tests that pass in a rerun drop out of the next `--last-failed` set; tests that did not run (filtered out by `--grep`, sharding, and so on) are not included.
203
+
- If the report does not exist, the command fails with "No previous run found". If the last run had no failures, it prints "No failed tests in the last run" and exits with code 0.
204
+
205
+
`--last-failed` is different from [run-rerun](#run-rerun), which repeats whole runs to detect flaky tests.
206
+
177
207
## Run Rerun <Badgetext="Since 3.3.6"type="warning"/>
178
208
179
209
Run tests multiple times to detect and fix flaky tests.
0 commit comments