Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: clarify beforeAll execution on exception (#28361)

Yury Semikhatskycea28b2df919
diff --git a/docs/src/test-api/class-test.md b/docs/src/test-api/class-test.md
index 6c3ac71d07..4fde7bb576 100644
--- a/docs/src/test-api/class-test.md
+++ b/docs/src/test-api/class-test.md
@@ -55,6 +55,8 @@ When called in the scope of a test file, runs after all tests in the file. When
Note that worker process is restarted on test failures, and `afterAll` hook runs again in the new worker. Learn more about [workers and failures](../test-retries.md).
+Playwright will continue running all applicable hooks even if some of them have failed.
+
**Usage**
```js
@@ -76,6 +78,10 @@ Hook function that takes one or two arguments: an object with worker fixtures an
Declares an `afterAll` hook with a title that is executed once per worker after all tests.
+**Details**
+
+See [`method: Test.afterAll#1`].
+
**Usage**
```js
@@ -110,6 +116,8 @@ When called in the scope of a test file, runs after each test in the file. When
You can access all the same [Fixtures] as the test function itself, and also the [TestInfo] object that gives a lot of useful information. For example, you can check whether the test succeeded or failed.
+Playwright will continue running all applicable hooks even if some of them have failed.
+
**Usage**
```js title="example.spec.ts"
@@ -139,6 +147,10 @@ Hook function that takes one or two arguments: an object with fixtures and optio
Declares an `afterEach` hook with a title that is executed after each test.
+**Details**
+
+See [`method: Test.afterEach#1`].
+
**Usage**
```js title="example.spec.ts"
@@ -181,6 +193,8 @@ When called in the scope of a test file, runs before all tests in the file. When
Note that worker process is restarted on test failures, and `beforeAll` hook runs again in the new worker. Learn more about [workers and failures](../test-retries.md).
+Playwright will continue running all applicable hooks even if some of them have failed.
+
You can use [`method: Test.afterAll#1`] to teardown any resources set up in `beforeAll`.
**Usage**
@@ -213,6 +227,10 @@ Hook function that takes one or two arguments: an object with worker fixtures an
Declares a `beforeAll` hook with a title that is executed once per worker process before all tests.
+**Details**
+
+See [`method: Test.beforeAll#1`].
+
**Usage**
```js title="example.spec.ts"
@@ -252,6 +270,8 @@ When called in the scope of a test file, runs before each test in the file. When
You can access all the same [Fixtures] as the test function itself, and also the [TestInfo] object that gives a lot of useful information. For example, you can navigate the page before starting the test.
+Playwright will continue running all applicable hooks even if some of them have failed.
+
You can use [`method: Test.afterEach#1`] to teardown any resources set up in `beforeEach`.
**Usage**
@@ -281,6 +301,10 @@ Hook function that takes one or two arguments: an object with fixtures and optio
Declares a `beforeEach` hook with a title that is executed before each test.
+**Details**
+
+See [`method: Test.beforeEach#1`].
+
**Usage**
```js title="example.spec.ts"
diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts
index bbf9da8314..d8a7d5b8bd 100644
--- a/packages/playwright/types/test.d.ts
+++ b/packages/playwright/types/test.d.ts
@@ -3072,6 +3072,8 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
* You can access all the same {@link Fixtures} as the test function itself, and also the {@link TestInfo} object that
* gives a lot of useful information. For example, you can navigate the page before starting the test.
*
+ * Playwright will continue running all applicable hooks even if some of them have failed.
+ *
* You can use [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1) to
* teardown any resources set up in `beforeEach`.
*
@@ -3097,6 +3099,10 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
/**
* Declares a `beforeEach` hook with a title that is executed before each test.
*
+ * **Details**
+ *
+ * See [test.beforeEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-each-1).
+ *
* **Usage**
*
* ```js
@@ -3129,6 +3135,8 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
* You can access all the same {@link Fixtures} as the test function itself, and also the {@link TestInfo} object that
* gives a lot of useful information. For example, you can check whether the test succeeded or failed.
*
+ * Playwright will continue running all applicable hooks even if some of them have failed.
+ *
* **Usage**
*
* ```js
@@ -3153,6 +3161,10 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
/**
* Declares an `afterEach` hook with a title that is executed after each test.
*
+ * **Details**
+ *
+ * See [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each-1).
+ *
* **Usage**
*
* ```js
@@ -3187,6 +3199,8 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
* Note that worker process is restarted on test failures, and `beforeAll` hook runs again in the new worker. Learn
* more about [workers and failures](https://playwright.dev/docs/test-retries).
*
+ * Playwright will continue running all applicable hooks even if some of them have failed.
+ *
* You can use [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all-1) to teardown
* any resources set up in `beforeAll`.
*
@@ -3215,6 +3229,10 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
/**
* Declares a `beforeAll` hook with a title that is executed once per worker process before all tests.
*
+ * **Details**
+ *
+ * See [test.beforeAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-before-all-1).
+ *
* **Usage**
*
* ```js
@@ -3246,6 +3264,8 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
* Note that worker process is restarted on test failures, and `afterAll` hook runs again in the new worker. Learn
* more about [workers and failures](https://playwright.dev/docs/test-retries).
*
+ * Playwright will continue running all applicable hooks even if some of them have failed.
+ *
* **Usage**
*
* ```js
@@ -3261,6 +3281,10 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
/**
* Declares an `afterAll` hook with a title that is executed once per worker after all tests.
*
+ * **Details**
+ *
+ * See [test.afterAll(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-all-1).
+ *
* **Usage**
*
* ```js