From ae10d56836d35006002feecc6b538f41d290a012 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 20 Nov 2024 09:06:54 +0100 Subject: [PATCH] docs(fixtures): add rules of thumb for fixture usage (#33472) --- docs/src/test-fixtures-js.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/test-fixtures-js.md b/docs/src/test-fixtures-js.md index 69c080297f..1d19d0acdb 100644 --- a/docs/src/test-fixtures-js.md +++ b/docs/src/test-fixtures-js.md @@ -115,8 +115,8 @@ test.describe('todo tests', () => { ### With fixtures Fixtures have a number of advantages over before/after hooks: -- Fixtures **encapsulate** setup and teardown in the same place so it is easier to write. -- Fixtures are **reusable** between test files - you can define them once and use in all your tests. That's how Playwright's built-in `page` fixture works. +- Fixtures **encapsulate** setup and teardown in the same place so it is easier to write. So if you have an after hook that tears down what was created in a before hook, consider turning them into a fixture. +- Fixtures are **reusable** between test files - you can define them once and use in all your tests. That's how Playwright's built-in `page` fixture works. So if you have a helper function that is used in multiple tests, consider turning it into a fixture. - Fixtures are **on-demand** - you can define as many fixtures as you'd like, and Playwright Test will setup only the ones needed by your test and nothing else. - Fixtures are **composable** - they can depend on each other to provide complex behaviors. - Fixtures are **flexible**. Tests can use any combinations of the fixtures to tailor precise environment they need, without affecting other tests.