docs(fixtures): add rules of thumb for fixture usage (#33472)
This commit is contained in:
Родитель
402bb4ccf8
Коммит
ae10d56836
|
@ -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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче