docs: add info about merging fixtures to fixtures page (#28468)

This commit is contained in:
jaktestowac.pl 2023-12-06 02:02:55 +01:00 committed by GitHub
parent 6838484ab5
commit 297f2af16b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1061,3 +1061,23 @@ A few observations:
* `testFixture` depends on `workerFixture` and triggers its setup.
* `workerFixture` is lazily set up before the second test, but teared down once during worker shutdown, as a worker-scoped fixture.
* `autoWorkerFixture` is set up for `beforeAll` hook, but `autoTestFixture` is not.
## Combine custom fixtures from multiple modules
You can merge test fixtures from multiple files or modules:
```js title="fixtures.ts"
import { mergeTests } from '@playwright/test';
import { test as dbTest } from 'database-test-utils';
import { test as a11yTest } from 'a11y-test-utils';
export const test = mergeTests(dbTest, a11yTest);
```
```js title="test.spec.ts"
import { test } from './fixtures';
test('passes', async ({ database, page, a11y }) => {
// use database and a11y fixtures.
});
```