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 350d96c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/src/test-api/class-testconfig.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -502,10 +502,14 @@ Whether to skip entries from `.gitignore` when searching for test files. By defa
502
502
503
503
## property: TestConfig.retries
504
504
* since: v1.10
505
-
- type: ?<[int]>
505
+
- type: ?<[int]|[Array]<[Object]>>
506
+
-`count` <[int]> The maximum number of retries given to a failed test when this entry applies.
507
+
-`condition` ?<[RegExp]> Regular expression matched against the error messages of the failed attempt. An entry without a condition always applies.
506
508
507
509
The maximum number of retry attempts given to failed tests. By default failing tests are not retried. Learn more about [test retries](../test-retries.md#retries).
508
510
511
+
When set to a list, the number of retries depends on the error. After each failed attempt, Playwright takes the largest `count` among the entries that apply, and retries the test when it has run fewer times than that. The latest failed attempt decides: a test that first fails with a matching error and then with a different one only gets the retries of the latter. Worker crashes and timeouts are matched by their error message like any other failure.
Copy file name to clipboardExpand all lines: docs/src/test-reporter-api/class-testcase.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ Results for each run of this test.
72
72
* since: v1.10
73
73
- type: <[int]>
74
74
75
-
The maximum number of retries given to this test in the configuration.
75
+
The maximum number of retries given to this test in the configuration. With conditional retries, this is updated after each failed attempt to the number of retries that applies to that failure.
76
76
77
77
Learn more about [test retries](../test-retries.md#retries).
Copy file name to clipboardExpand all lines: docs/src/test-retries-js.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,25 @@ test.describe(() => {
127
127
});
128
128
```
129
129
130
+
### Conditional retries
131
+
132
+
The number of retries can depend on the error. Give a list of entries, each with a `count` and an optional `condition` regular expression. After each failed attempt, the largest `count` among the entries whose condition matches an error message of that attempt applies. An entry without a condition always applies.
133
+
134
+
```js title="playwright.config.ts"
135
+
import { defineConfig } from'@playwright/test';
136
+
137
+
exportdefaultdefineConfig({
138
+
retries: [
139
+
// Retry any failure once.
140
+
{ count:1 },
141
+
// Retry up to three times when the browser or the worker crashed.
142
+
{ count:3, condition:/Target crashed|worker process exited unexpectedly/ },
143
+
],
144
+
});
145
+
```
146
+
147
+
Worker crashes and timeouts are matched by their error message like any other failure. The latest failed attempt decides: a test that first crashes and then fails on an assertion only gets the retries of the assertion failure.
148
+
130
149
## Serial mode
131
150
132
151
Use [`method: Test.describe.serial`] to group dependent tests to ensure they will always run together and in order. If one of the tests fails, all subsequent tests are skipped. All tests in the group are retried together.
0 commit comments