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);
},
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.

Further reading

Problem with a question

Playwright · Middle · question 9

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz