docs: enhance hooks example to illustrate after hooks behavior (#26846)
Fixes https://github.com/microsoft/playwright/issues/26821
This commit is contained in:
parent
1c5f53f216
commit
afd4363aab
|
|
@ -19,6 +19,7 @@ test.describe('suite', () => {
|
|||
test('first good', async ({ page }) => { /* ... */ });
|
||||
test('second flaky', async ({ page }) => { /* ... */ });
|
||||
test('third good', async ({ page }) => { /* ... */ });
|
||||
test.afterAll(async () => { /* ... */ });
|
||||
});
|
||||
```
|
||||
|
||||
|
|
@ -28,25 +29,30 @@ When **all tests pass**, they will run in order in the same worker process.
|
|||
* `first good` passes
|
||||
* `second flaky` passes
|
||||
* `third good` passes
|
||||
* `afterAll` hook runs
|
||||
|
||||
Should **any test fail**, Playwright Test will discard the entire worker process along with the browser and will start a new one. Testing will continue in the new worker process starting with the next test.
|
||||
* Worker process #1 starts
|
||||
* `beforeAll` hook runs
|
||||
* `first good` passes
|
||||
* `second flaky` fails
|
||||
* `afterAll` hook runs
|
||||
* Worker process #2 starts
|
||||
* `beforeAll` hook runs again
|
||||
* `third good` passes
|
||||
* `afterAll` hook runs
|
||||
|
||||
If you **enable [retries](#retries)**, second worker process will start by retrying the failed test and continue from there.
|
||||
* Worker process #1 starts
|
||||
* `beforeAll` hook runs
|
||||
* `first good` passes
|
||||
* `second flaky` fails
|
||||
* `afterAll` hook runs
|
||||
* Worker process #2 starts
|
||||
* `beforeAll` hook runs again
|
||||
* `second flaky` is retried and passes
|
||||
* `third good` passes
|
||||
* `afterAll` hook runs
|
||||
|
||||
This scheme works perfectly for independent tests and guarantees that failing tests can't affect healthy ones.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue