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 0692d80
Browse filesBrowse the repository at this point in the historyBrowse files
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>
.option('-g, --grep <pattern>','only run tests matching <pattern>')
209
210
.option('-i, --invert','inverts --grep matches')
211
+
.option('--last-failed','run only tests that failed in the previous run')
210
212
.option('-o, --override [value]','override current config options')
211
213
.option('--suites','parallel execution of suites not single tests')
212
214
.option('--by <strategy>','test distribution strategy: "test" (pre-assign individual tests), "suite" (pre-assign test suites), or "pool" (dynamic distribution for optimal load balancing, recommended)')
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
@@ -157,6 +165,9 @@ npx codeceptjs run-workers 3 --by suite
157
165
158
166
# Pool mode with filtering
159
167
npx codeceptjs run-workers 4 --by pool --grep "@smoke"
168
+
169
+
# Rerun only tests that failed in the previous run
170
+
npx codeceptjs run-workers 3 --last-failed
160
171
```
161
172
162
173
**Test Distribution Strategies:**
@@ -169,6 +180,25 @@ The pool mode provides the best load balancing by maintaining tests in a shared
169
180
170
181
See [Parallel Execution](/parallel) documentation for more details.
171
182
183
+
## Last Failed
184
+
185
+
Rerun only the tests that failed in the previous run. Works with `run` and `run-workers`, including all `--by` strategies:
186
+
187
+
```sh
188
+
npx codeceptjs run --last-failed
189
+
npx codeceptjs run-workers 3 --last-failed
190
+
```
191
+
192
+
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`:
193
+
194
+
- Skipped and pending tests are not considered failed.
195
+
- Tests are matched by their title, including the Feature title. A renamed test or Feature is not matched.
196
+
- Combined with `--grep`, only failed tests that also match the pattern are run.
197
+
- 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.
198
+
- 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.
199
+
200
+
`--last-failed` is different from [run-rerun](#run-rerun), which repeats whole runs to detect flaky tests.
201
+
172
202
## Run Rerun <Badgetext="Since 3.3.6"type="warning"/>
173
203
174
204
Run tests multiple times to detect and fix flaky tests.
0 commit comments