Skip to content

Commit

Permalink
fix: spec
Browse files Browse the repository at this point in the history
  • Loading branch information
9renpoto committed Oct 7, 2023
1 parent b5af6e6 commit 1a58880
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 48 deletions.
9 changes: 1 addition & 8 deletions apps/web/e2e/index.spec.ts
Original file line number Diff line number Diff line change
@@ -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",
);
});
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build": "next build",
"dev": "next dev",
"start": "next start",
"playwright": "playwright",
"test": "playwright test"
},
"dependencies": {
Expand Down
41 changes: 1 addition & 40 deletions apps/web/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"],
},
],
});

0 comments on commit 1a58880

Please sign in to comment.