✨ Add initial setup for frontend / end-to-end tests with Playwright (#1261)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
12
frontend/tests/auth.setup.ts
Normal file
12
frontend/tests/auth.setup.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { test as setup } from "@playwright/test"
|
||||
|
||||
const authFile = "playwright/.auth/user.json"
|
||||
|
||||
setup("authenticate", async ({ page }) => {
|
||||
await page.goto("/login")
|
||||
await page.getByPlaceholder("Email").fill("admin@example.com")
|
||||
await page.getByPlaceholder("Password").fill("changethis")
|
||||
await page.getByRole("button", { name: "Log In" }).click()
|
||||
await page.waitForURL("/")
|
||||
await page.context().storageState({ path: authFile })
|
||||
})
|
8
frontend/tests/example.spec.ts
Normal file
8
frontend/tests/example.spec.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test('has title', async ({ page }) => {
|
||||
await page.goto('https://playwright.dev/');
|
||||
|
||||
// Expect a title "to contain" a substring.
|
||||
await expect(page).toHaveTitle(/Playwright/);
|
||||
});
|
Reference in New Issue
Block a user