Declares a beforeAll hook that is executed once per worker process before all tests.
When called in the scope of a test file, runs before all tests in the file. When called inside a
test.describe([title, details, callback]) group, runs
before all tests in the group.
Declares a
beforeAll
hook that is executed once per worker process before all tests.When called in the scope of a test file, runs before all tests in the file. When called inside a test.describe([title, details, callback]) group, runs before all tests in the group.
You can use test.afterAll([title, hookFunction]) to teardown any resources set up in
beforeAll
.test.beforeAll(hookFunction)
test.beforeAll(title, hookFunction)
Details
When multiple
beforeAll
hooks are added, they will run in the order of their registration.Note that worker process is restarted on test failures, and
beforeAll
hook runs again in the new worker. Learn more about workers and failures.Playwright will continue running all applicable hooks even if some of them have failed.
Usage
Alternatively, you can declare a hook with a title.