Testing · Senior · Question 44 of 75

How do you implement authentication once for the whole suite in Playwright?

projects: [
  { name: "setup", testMatch: /auth\.setup\.ts/ },
  { name: "chromium", use: { storageState: "playwright/.auth/user.json" }, dependencies: ["setup"] },
]

Explanation

Project dependencies appear in the report and trace, unlike globalSetup. Keep the auth file out of git.

Further reading

Problem with a question

Testing · Senior · question 44

Test yourself

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

Take this quiz