diff --git a/apps/web/e2e/index.spec.ts b/apps/web/e2e/index.spec.ts index 873f2023..5ad6ee21 100644 --- a/apps/web/e2e/index.spec.ts +++ b/apps/web/e2e/index.spec.ts @@ -1,14 +1,7 @@ import { expect, test } from "@playwright/test"; test("should navigate to the about page", async ({ page }) => { - // Start from the index page (the baseURL is set via the webServer in the playwright.config.ts) await page.goto("/"); - // Find an element with the text 'About Page' and click on it - await page.getByText("About Page").click(); - // The new url should be "/about" (baseURL is used there) + await page.getByText("About").click(); await expect(page).toHaveURL("/about"); - // The new page should contain an h1 with "About Page" - await expect(page.getByRole("heading", { level: 1 })).toContainText( - "About Page", - ); }); diff --git a/apps/web/package.json b/apps/web/package.json index 36f42461..5d4a1e40 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -7,6 +7,7 @@ "build": "next build", "dev": "next dev", "start": "next start", + "playwright": "playwright", "test": "playwright test" }, "dependencies": { diff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.ts index f97c6d06..161e1732 100644 --- a/apps/web/playwright.config.ts +++ b/apps/web/playwright.config.ts @@ -4,22 +4,15 @@ import path from "path"; // Use process.env.PORT by default and fallback to port 3000 const PORT = process.env.PORT || 3000; -// Set webServer.url and use.baseURL with the location of the WebServer respecting the correct set port const baseURL = `http://localhost:${PORT}`; // Reference: https://playwright.dev/docs/test-configuration export default defineConfig({ - // Timeout per test timeout: 30 * 1000, - // Test directory testDir: path.join(__dirname, "e2e"), - // If a test fails, retry it additional 2 times retries: 2, - // Artifacts folder where screenshots, videos, and traces are stored. outputDir: "test-results/", - // Run your local dev server before starting the tests: - // https://playwright.dev/docs/test-advanced#launching-a-development-web-server-during-the-tests webServer: { command: "npm run dev", url: baseURL, @@ -28,48 +21,16 @@ export default defineConfig({ }, use: { - // Use baseURL so to make navigations relative. - // More information: https://playwright.dev/docs/api/class-testoptions#test-options-base-url baseURL, - - // Retry a test if its failing with enabled tracing. This allows you to analyze the DOM, console logs, network traffic etc. - // More information: https://playwright.dev/docs/trace-viewer trace: "retry-with-trace", - // All available context options: https://playwright.dev/docs/api/class-browser#browser-new-context - // contextOptions: { - // ignoreHTTPSErrors: true, - // }, }, projects: [ - { - name: "Desktop Chrome", - use: { - ...devices["Desktop Chrome"], - }, - }, - // { - // name: 'Desktop Firefox', - // use: { - // ...devices['Desktop Firefox'], - // }, - // }, - // { - // name: 'Desktop Safari', - // use: { - // ...devices['Desktop Safari'], - // }, - // }, - // Test against mobile viewports. { name: "Mobile Chrome", use: { - ...devices["Pixel 5"], + ...devices["iPhone 13 Mini"], }, }, - { - name: "Mobile Safari", - use: devices["iPhone 12"], - }, ], });