Playwright · Middle · Question 9 of 75
When does teardown code in a fixture run?
myFixture: async ({}, use) => {
const user = await createUser();
await use(user);
await deleteUser(user.id);
},- 1Before the test, as part of the setup step
- 2Only when the test using it has passed
- 3After the test finishes, even when it fails
Show the answer
Correct answer: After the test finishes, even when it fails
Explanation
Code after await use() runs after the test, whatever its result. This keeps cleanup next to setup.