auth.setup.js)import { test as setup } from "@playwright/test";const authFile = "playwright/.auth/user.json";
setup("authenticate user", async ({ page }) => {
await page.goto("/login");
await page.getByLabel("Email").fill("tester@targetqa.com");
await page.getByLabel("Password").fill("Secret123!");
await page.getByRole("button", { name: "Sign In" }).click();
await page.waitForURL("**/dashboard");
// Save session state to disk:
await page.context().storageState({ path: authFile });
});