Skip to content

Commit

Permalink
fix parallel e2e runs
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin authored and vicb committed Sep 16, 2024
1 parent fca7363 commit f41276c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 18 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ jobs:
run: npm install -g pnpm && pnpm install
- name: Install Playwright browsers
run: pnpm run install-playwright
- name: Run Playwright tests
run: pnpm run e2e
# - uses: actions/upload-artifact@v4
# if: always()
# with:
# name: api-playwright-report
# path: next-apps/*/playwright-report/
# retention-days: 30
- name: Run playwright tests (api)
run: pnpm -F api run e2e
- name: Run playwright tests (create-next-app)
run: pnpm -F create-next-app run e2e
6 changes: 3 additions & 3 deletions examples/api/e2e-tests/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { test, expect } from "@playwright/test";
test("the application's noop index page is visible and it allows navigating to the hello-world api route", async ({
page,
}) => {
await page.goto("http://localhost:8770/");
await page.goto("/");
await expect(page.getByText("This application doesn't have")).toBeVisible();
await page.getByRole("link", { name: "/api/hello" }).click();
await expect(page.getByText("Hello World!")).toBeVisible();
});

test("the hello-world api route works as intended", async ({ page }) => {
const res = await fetch("http://localhost:8770/api/hello");
expect(res.headers.get("content-type")).toContain("text/plain");
const res = await page.request.get("/api/hello");
expect(res.headers()["content-type"]).toContain("text/plain");
expect(await res.text()).toEqual("Hello World!");
});
1 change: 0 additions & 1 deletion examples/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"build:worker": "builder",
"dev:worker": "wrangler dev --port 8770",
"preview:worker": "pnpm build:worker && pnpm dev:worker",
"pree2e": "playwright install --with-deps",
"e2e": "playwright test"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/api/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: "http://localhost:8770",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
Expand Down
2 changes: 1 addition & 1 deletion examples/create-next-app/e2e/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { test, expect } from "@playwright/test";
test("the index page of the application shows the Next.js logo", async ({
page,
}) => {
await page.goto("http://localhost:8770/");
await page.goto("/");
await expect(page.getByAltText("Next.js logo")).toBeVisible();
});
4 changes: 2 additions & 2 deletions examples/create-next-app/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
baseURL: "http://localhost:8771",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
Expand Down Expand Up @@ -74,7 +74,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
command: "pnpm preview:worker",
url: "http://localhost:8770",
url: "http://localhost:8771",
reuseExistingServer: !process.env.CI,
},
});
3 changes: 1 addition & 2 deletions examples/create-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
"start": "next start",
"lint": "next lint",
"build:worker": "builder",
"dev:worker": "wrangler dev --port 8770",
"dev:worker": "wrangler dev --port 8771",
"preview:worker": "pnpm build:worker && pnpm dev:worker",
"pree2e": "playwright install --with-deps",
"e2e": "playwright test -c e2e/playwright.config.ts"
},
"dependencies": {
Expand Down

0 comments on commit f41276c

Please sign in to comment.