Skip to content

Commit 5471712

Browse files
authored
test: run e2e tests with both webpack and turbopack (#1018)
1 parent 2a3ee86 commit 5471712

15 files changed

+60
-21
lines changed

.github/workflows/playwright.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ jobs:
1919
- name: Install Playwright
2020
uses: ./.github/actions/setup-playwright
2121

22-
- name: Build the tool
23-
run: pnpm build
24-
25-
- name: Build all workers
22+
- name: Build workers (webpack)
2623
run: pnpm -r build:worker
2724

28-
- name: Run playwright tests
25+
- name: Run playwright tests (webpack)
2926
run: pnpm e2e
3027

28+
- name: Build workers (turbopack)
29+
run: pnpm -r build:worker-turbopack
30+
31+
- name: Run playwright tests (turbopack)
32+
run: pnpm e2e-turbopack
33+
3134
- name: Run playwright dev tests
3235
run: pnpm e2e:dev
3336

examples/common/config-e2e.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
2+
import { execSync } from "node:child_process";
33
import { getAppPort, getInspectorPort, type AppName } from "./apps";
44

55
declare const process: typeof nodeProcess;
@@ -15,6 +15,8 @@ export function configurePlaywright(
1515
multipleBrowsers = false,
1616
// Whether to run tests in single file in parallel
1717
parallel = true,
18+
// Use the turbopack runtime
19+
useTurbopack = false,
1820
} = {}
1921
) {
2022
const port = getAppPort(app, { isWorker });
@@ -23,15 +25,12 @@ export function configurePlaywright(
2325
let command: string;
2426
let timeout: number;
2527
if (isWorker) {
28+
// Do not build on CI - there is a preceding build step
29+
command = isCI ? "" : `pnpm ${useTurbopack ? "build:worker-turbopack" : "build:worker"} && `;
30+
2631
const env = app === "r2-incremental-cache" ? "--env e2e" : "";
27-
if (isCI) {
28-
// Do not build on CI - there is a preceding build step
29-
command = `pnpm preview:worker -- --port ${port} --inspector-port ${inspectorPort} ${env}`;
30-
timeout = 800_000;
31-
} else {
32-
timeout = 800_000;
33-
command = `pnpm preview -- --port ${port} --inspector-port ${inspectorPort} ${env}`;
34-
}
32+
command += `pnpm preview:worker -- --port ${port} --inspector-port ${inspectorPort} ${env}`;
33+
timeout = 800_000;
3534
} else {
3635
timeout = 100_000;
3736
command = `pnpm dev --port ${port}`;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { configurePlaywright } from "../../../common/config-e2e";
22

3-
export default configurePlaywright("app-pages-router");
3+
export default configurePlaywright("app-pages-router", { useTurbopack: false });
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { configurePlaywright } from "../../../common/config-e2e";
2+
3+
export default configurePlaywright("app-pages-router", { useTurbopack: true });
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import config from "./open-next.config.js";
2+
3+
export default {
4+
...config,
5+
// Override the build command to use Turbopack
6+
buildCommand: "next build --turbopack",
7+
};

examples/e2e/app-pages-router/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"build:worker": "pnpm opennextjs-cloudflare build",
1313
"preview:worker": "pnpm opennextjs-cloudflare preview",
1414
"preview": "pnpm build:worker && pnpm preview:worker",
15-
"e2e": "playwright test -c e2e/playwright.config.ts"
15+
"e2e": "playwright test -c e2e/playwright.config.ts",
16+
"build:worker-turbopack": "pnpm opennextjs-cloudflare build --openNextConfigPath open-next.turbopack.config.ts",
17+
"e2e-turbopack": "playwright test -c e2e/playwright.turbopack.config.ts"
1618
},
1719
"dependencies": {
1820
"@opennextjs/cloudflare": "workspace:*",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { configurePlaywright } from "../../../common/config-e2e";
22

3-
export default configurePlaywright("app-router");
3+
export default configurePlaywright("app-router", { useTurbopack: false });
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { configurePlaywright } from "../../../common/config-e2e";
2+
3+
export default configurePlaywright("app-router", { useTurbopack: true });
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import config from "./open-next.config.js";
2+
3+
export default {
4+
...config,
5+
// Override the build command to use Turbopack
6+
buildCommand: "next build --turbopack",
7+
};

examples/e2e/app-router/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"build:worker": "pnpm opennextjs-cloudflare build",
1313
"preview:worker": "pnpm opennextjs-cloudflare preview",
1414
"preview": "pnpm build:worker && pnpm preview:worker",
15-
"e2e": "playwright test -c e2e/playwright.config.ts"
15+
"e2e": "playwright test -c e2e/playwright.config.ts",
16+
"build:worker-turbopack": "pnpm build:worker --openNextConfigPath open-next.turbopack.config.ts",
17+
"e2e-turbopack": "playwright test -c e2e/playwright.turbopack.config.ts"
1618
},
1719
"dependencies": {
1820
"@opennextjs/cloudflare": "workspace:*",

0 commit comments

Comments
 (0)