Skip to content

Commit

Permalink
docs(fixtures): add rules of thumb for fixture usage (#33472)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt authored Nov 20, 2024
1 parent 402bb4c commit ae10d56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/test-fixtures-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ae10d56

Please sign in to comment.