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 0a2ecc9
Browse filesBrowse the repository at this point in the historyBrowse files
authored
feat(workers): run serial tests after parallel workers (#5728)
* feat(workers): run serial tests after parallel workers
Tests matching the new `serial` config pattern are kept out of the
parallel workers. Once those exit, one more worker starts and runs the
serial tests one by one, inside the same run: bootstrapAll, teardownAll
and workers.result fire once and the exit code covers both parts.
Works with every --by strategy and combines with --grep.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(workers): add --serial option to run-workers
Sets or overrides the serial config pattern for a single run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: DavertMik <davert@testomat.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: bin/codecept.js
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -209,6 +209,7 @@ program
209
209
.option('-i, --invert','inverts --grep matches')
210
210
.option('-o, --override [value]','override current config options')
211
211
.option('--suites','parallel execution of suites not single tests')
212
+
.option('--serial <pattern>','run tests matching <pattern> one by one after parallel workers finish')
212
213
.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)')
-`--by suite`: Pre-assigns entire test suites to workers
166
169
-`--by pool`: Dynamic distribution for optimal load balancing (recommended for best performance)
167
170
171
+
`--serial <pattern>` keeps tests matching the pattern out of parallel workers and runs them one by one in an extra worker once the others finish, within the same run. It overrides the `serial` config option. See [Serial tests](/parallel#serial-tests).
172
+
168
173
The pool mode provides the best load balancing by maintaining tests in a shared pool and distributing them dynamically as workers become available. This prevents workers from sitting idle and ensures optimal CPU utilization, especially when tests have varying execution times.
169
174
170
175
See [Parallel Execution](/parallel) documentation for more details.
Copy file name to clipboardExpand all lines: docs/configuration.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ export const config = {
44
44
45
45
-`timeout` — default per-test timeout in seconds; a test is killed if it stops responding.
46
46
-`mocha` — [Mocha options](https://mochajs.org/#configuring-mocha-nodejs), including extra reporters. See [Reporters](/reports).
47
+
-`serial` — pattern for tests that must not run in parallel, e.g. `serial: '@serial'`. With `run-workers` they run one by one after all parallel workers finish. `--serial` overrides it. See [Serial tests](/parallel#serial-tests).
47
48
-`workerInitializationDelay` — delay in milliseconds between spinning up parallel workers to prevent CPU spikes and stagger browser startup. Defaults to `200`. Set to `0` to disable.
48
49
-`workerInitializationMaxDelay` — maximum total delay (in milliseconds) for worker initialization staggering. Defaults to `10000` (10 s). Set to `0` to disable capping.
Copy file name to clipboardExpand all lines: docs/parallel.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,40 @@ npx codeceptjs run-workers 4 --by pool
40
40
41
41
`--suites` is shorthand for `--by suite`.
42
42
43
+
### Serial tests
44
+
45
+
Some tests can't share the stage: they change global settings, reset data, or toggle a feature flag that other tests read. Mark them with a tag and set the `serial` pattern in config or pass it with `--serial`:
46
+
47
+
```js
48
+
// codecept.conf.js
49
+
exportconstconfig= {
50
+
serial:'@serial',
51
+
}
52
+
```
53
+
54
+
```js
55
+
Scenario('change account timezone @serial', ({ I }) => {
56
+
// ...
57
+
})
58
+
```
59
+
60
+
`run-workers` keeps matching tests out of the parallel workers. When those workers finish, one more worker starts and runs the serial tests one by one. It is still a single run: `bootstrapAll`, `teardownAll` and `event.workers.result` fire once, and the exit code covers both parts.
61
+
62
+
```
63
+
Test distribution:
64
+
Worker 1: 14 tests
65
+
Worker 2: 13 tests
66
+
Worker 3: 4 tests (serial)
67
+
```
68
+
69
+
Pass `--serial` to set or override the pattern for a single run:
70
+
71
+
```sh
72
+
npx codeceptjs run-workers 3 --serial "@serial"
73
+
```
74
+
75
+
`serial` is matched against the full test title the same way `--grep` is, so a tag on a `Feature` makes all its scenarios serial. It works with every `--by` strategy and combines with `--grep`: only serial tests that also match grep are run. With [multiple browsers](#multiple-browsers) each profile gets its own serial worker, started one after another.
76
+
43
77
### Multiple browsers
44
78
45
79
Define browser profiles under `multiple` in `codecept.conf.js`:
0 commit comments