A fixture is a value a test receives, set up before the test and torn down after it, even when the test fails. Use one to create test data. To sign in, use a saved session instead.
Define fixtures in one file
Extend your engine’s test and export it. A fixture can use agent, so it
can create its data through the app with goals:
Code before await use(value) is the setup, and code after it is the
teardown. Import the extended test in your test files:
The saved session is restored before the fixtures run.
Agent steps in a fixture run for every test that uses it. If your app has a
test API, a fetch call is faster.
Build one fixture on another
A fixture can read only the fixtures of the test it extends. So task
uses project through a second extend. Teardown runs in reverse order.
Give each setup its own test
Every fixture in a chain runs for every test registered through it, named
or not. Export one test for each setup, like test and taskTest above.
Read fixtures in hooks
Register the hook on your extended test to get the fixture types:
When a fixture fails
An error in setup fails the test in beforeEach. An error in teardown is
reported in afterEach. See the full list of mistakes.