From 297f2af16b6ed6ea739838e53033dec8f946c83c Mon Sep 17 00:00:00 2001 From: "jaktestowac.pl" <72373858+jaktestowac@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:02:55 +0100 Subject: [PATCH] docs: add info about merging fixtures to fixtures page (#28468) --- docs/src/test-fixtures-js.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/src/test-fixtures-js.md b/docs/src/test-fixtures-js.md index ff721c7261..33febcb5aa 100644 --- a/docs/src/test-fixtures-js.md +++ b/docs/src/test-fixtures-js.md @@ -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. +}); +``` \ No newline at end of file