Skip to content

Commit 1fd08b3

Browse files
authored
refactor: simplify the e2e and script configs (#342)
1 parent e1b3711 commit 1fd08b3

29 files changed

+211
-599
lines changed

CONTRIBUTING.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ Any contributions you make will be via [Pull Requests](https://docs.github.com/e
2525

2626
```sh
2727
> git remote -v
28-
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
29-
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
28+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
29+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
3030
```
3131

3232
- Add `opennextjs/opennextjs-cloudflare` as the `upstream` remote repository.
3333

3434
```sh
3535
> git remote add upstream https://github.com/opennextjs/opennextjs-cloudflare
3636
> git remote -v
37-
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
38-
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
39-
upstream https://github.com/opennextjs/opennextjs-cloudflare (fetch)
40-
upstream https://github.com/opennextjs/opennextjs-cloudflare (push)
37+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (fetch)
38+
origin https://github.com/<your-github-username>/opennextjs-cloudflare (push)
39+
upstream https://github.com/opennextjs/opennextjs-cloudflare (fetch)
40+
upstream https://github.com/opennextjs/opennextjs-cloudflare (push)
4141
```
4242

4343
- You should regularly pull from the `main` branch of the `upstream` repository to keep up to date with the latest changes to the project.
@@ -82,13 +82,13 @@ pnpm --filter cloudflare build:watch
8282
Build and preview a Next.js sample application. For example, the `api` application:
8383

8484
```sh
85-
pnpm --filter api preview:worker
85+
pnpm --filter api preview
8686
```
8787

8888
You can skip building the Next.js app when it has not been modified, and only run the Cloudflare adaptor tool:
8989

9090
```sh
91-
SKIP_NEXT_APP_BUILD=true pnpm --filter api preview:worker
91+
SKIP_NEXT_APP_BUILD=true pnpm --filter api preview
9292
```
9393

9494
## Checking the code
@@ -102,7 +102,7 @@ pnpm run code:checks
102102
Attempt to auto-fix any issues with the format, lint and type checks:
103103

104104
```sh
105-
pnpm run code:fixes
105+
pnpm run fix
106106
```
107107

108108
## Testing the code
@@ -117,6 +117,7 @@ Run all the e2e tests, via Playwright:
117117

118118
```sh
119119
pnpm run e2e
120+
pnpm run e2e:dev
120121
```
121122

122123
## Changesets
@@ -127,15 +128,15 @@ We use the [`changesets`](https://github.com/changesets/changesets/blob/main/REA
127128
- Create a changeset for the current change.
128129

129130
```sh
130-
> pnpm changeset
131+
pnpm changeset
131132
```
132133

133134
- Select which workspaces are affected by the change and whether the version requires a major, minor or patch release.
134135
- Update the generated changeset with a description of the change.
135136
- Include the generate changeset in the current commit.
136137

137138
```sh
138-
> git add ./changeset/*.md
139+
git add ./changeset/*.md
139140
```
140141

141142
### Changeset message format

examples/api/e2e/playwright.config.ts

+2-54
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,3 @@
1-
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
1+
import { configurePlaywright } from "../../common/config-e2e";
32

4-
declare const process: typeof nodeProcess;
5-
6-
/**
7-
* See https://playwright.dev/docs/test-configuration.
8-
*/
9-
export default defineConfig({
10-
testDir: "./",
11-
/* Run tests in files in parallel */
12-
fullyParallel: true,
13-
/* Fail the build on CI if you accidentally left test.only in the source code. */
14-
forbidOnly: !!process.env.CI,
15-
/* Retry on CI only */
16-
retries: process.env.CI ? 2 : 0,
17-
/* Opt out of parallel tests on CI. */
18-
workers: process.env.CI ? 1 : undefined,
19-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
20-
reporter: "html",
21-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
22-
use: {
23-
/* Base URL to use in actions like `await page.goto('/')`. */
24-
baseURL: "http://localhost:8770",
25-
26-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27-
trace: "on-first-retry",
28-
},
29-
30-
/* Configure projects for major browsers */
31-
projects: [
32-
{
33-
name: "chromium",
34-
use: { ...devices["Desktop Chrome"] },
35-
},
36-
37-
{
38-
name: "firefox",
39-
use: { ...devices["Desktop Firefox"] },
40-
},
41-
42-
{
43-
name: "webkit",
44-
use: { ...devices["Desktop Safari"] },
45-
},
46-
],
47-
48-
/* Run your local dev server before starting the tests */
49-
webServer: {
50-
command: "pnpm preview:worker",
51-
url: "http://localhost:8770",
52-
reuseExistingServer: !process.env.CI,
53-
timeout: 500_000,
54-
},
55-
});
3+
export default configurePlaywright("api", { isCI: !!process.env.CI });
+5-53
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,7 @@
1-
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
1+
import { configurePlaywright } from "../../common/config-e2e";
32

4-
declare const process: typeof nodeProcess;
5-
6-
/**
7-
* See https://playwright.dev/docs/test-configuration.
8-
*/
9-
export default defineConfig({
10-
testDir: "./",
11-
testIgnore: "cloudflare.spec.ts",
12-
/* Run tests in files in parallel */
13-
fullyParallel: true,
14-
/* Fail the build on CI if you accidentally left test.only in the source code. */
15-
forbidOnly: !!process.env.CI,
16-
/* Retry on CI only */
17-
retries: process.env.CI ? 2 : 0,
18-
/* Opt out of parallel tests on CI. */
19-
workers: process.env.CI ? 1 : undefined,
20-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
21-
reporter: "html",
22-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
23-
use: {
24-
/* Base URL to use in actions like `await page.goto('/')`. */
25-
baseURL: "http://localhost:3333",
26-
27-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
28-
trace: "on-first-retry",
29-
},
30-
31-
/* Configure projects for major browsers */
32-
projects: [
33-
{
34-
name: "chromium",
35-
use: { ...devices["Desktop Chrome"] },
36-
},
37-
38-
{
39-
name: "firefox",
40-
use: { ...devices["Desktop Firefox"] },
41-
},
42-
43-
{
44-
name: "webkit",
45-
use: { ...devices["Desktop Safari"] },
46-
},
47-
],
48-
49-
/* Run your local dev server before starting the tests */
50-
webServer: {
51-
command: "pnpm dev --port 3333",
52-
url: "http://localhost:3333",
53-
reuseExistingServer: !process.env.CI,
54-
},
3+
export default configurePlaywright("api", {
4+
isCI: !!process.env.CI,
5+
isWorker: false,
6+
multipleBrowsers: false,
557
});

examples/api/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"start": "next start",
1010
"lint": "next lint",
1111
"build:worker": "pnpm opennextjs-cloudflare",
12-
"dev:worker": "wrangler dev --port 8770 --inspector-port 9330",
13-
"preview:worker": "pnpm build:worker && pnpm dev:worker",
12+
"preview": "pnpm build:worker && pnpm wrangler dev",
1413
"e2e": "playwright test -c e2e/playwright.config.ts",
1514
"e2e:dev": "playwright test -c e2e/playwright.dev.config.ts",
1615
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
+2-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
1-
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
1+
import { configurePlaywright } from "../../../common/config-e2e";
32

4-
declare const process: typeof nodeProcess;
5-
6-
/**
7-
* See https://playwright.dev/docs/test-configuration.
8-
*/
9-
export default defineConfig({
10-
testDir: "./",
11-
/* Run tests in files in parallel */
12-
fullyParallel: true,
13-
/* Fail the build on CI if you accidentally left test.only in the source code. */
14-
forbidOnly: !!process.env.CI,
15-
/* Retry on CI only */
16-
retries: process.env.CI ? 2 : 0,
17-
/* Opt out of parallel tests on CI. */
18-
workers: process.env.CI ? 1 : undefined,
19-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
20-
reporter: "html",
21-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
22-
use: {
23-
/* Base URL to use in actions like `await page.goto('/')`. */
24-
baseURL: "http://localhost:8750",
25-
26-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27-
trace: "on-first-retry",
28-
},
29-
30-
/* Configure projects for major browsers */
31-
projects: [
32-
{
33-
name: "chromium",
34-
use: { ...devices["Desktop Chrome"] },
35-
},
36-
],
37-
38-
/* Run your local dev server before starting the tests */
39-
webServer: {
40-
command: "pnpm preview",
41-
url: "http://localhost:8750",
42-
reuseExistingServer: !process.env.CI,
43-
timeout: 500_000,
44-
},
45-
});
3+
export default configurePlaywright("gh-119", { isCI: !!process.env.CI, multipleBrowsers: false });

examples/bugs/gh-119/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"build:worker": "pnpm opennextjs-cloudflare",
11-
"dev:worker": "wrangler dev --port 8750 --inspector-port 9370",
12-
"preview": "pnpm build:worker && pnpm dev:worker",
11+
"preview": "pnpm build:worker && pnpm wrangler dev",
1312
"e2e": "playwright test -c e2e/playwright.config.ts",
1413
"cf-typegen": "wrangler types --env-interface CloudflareEnv"
1514
},
+2-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
1-
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
1+
import { configurePlaywright } from "../../../common/config-e2e";
32

4-
declare const process: typeof nodeProcess;
5-
6-
/**
7-
* See https://playwright.dev/docs/test-configuration.
8-
*/
9-
export default defineConfig({
10-
testDir: "./",
11-
/* Run tests in files in parallel */
12-
fullyParallel: true,
13-
/* Fail the build on CI if you accidentally left test.only in the source code. */
14-
forbidOnly: !!process.env.CI,
15-
/* Retry on CI only */
16-
retries: process.env.CI ? 2 : 0,
17-
/* Opt out of parallel tests on CI. */
18-
workers: process.env.CI ? 1 : undefined,
19-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
20-
reporter: "html",
21-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
22-
use: {
23-
/* Base URL to use in actions like `await page.goto('/')`. */
24-
baseURL: "http://localhost:8751",
25-
26-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27-
trace: "on-first-retry",
28-
},
29-
30-
/* Configure projects for major browsers */
31-
projects: [
32-
{
33-
name: "chromium",
34-
use: { ...devices["Desktop Chrome"] },
35-
},
36-
],
37-
38-
/* Run your local dev server before starting the tests */
39-
webServer: {
40-
command: "pnpm preview",
41-
url: "http://localhost:8751",
42-
reuseExistingServer: !process.env.CI,
43-
timeout: 500_000,
44-
},
45-
});
3+
export default configurePlaywright("gh-219", { isCI: !!process.env.CI, multipleBrowsers: false });

examples/bugs/gh-219/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"build:worker": "opennextjs-cloudflare",
11-
"dev:worker": "wrangler dev --port 8751 --inspector-port 9371",
12-
"preview": "npm run build:worker && npm run dev:worker",
11+
"preview": "npm run build:worker && npx wrangler dev",
1312
"e2e": "playwright test -c e2e/playwright.config.ts",
1413
"deploy:worker": "npm run build:worker && wrangler deploy"
1514
},
+2-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,3 @@
1-
import { defineConfig, devices } from "@playwright/test";
2-
import type nodeProcess from "node:process";
1+
import { configurePlaywright } from "../../../common/config-e2e";
32

4-
declare const process: typeof nodeProcess;
5-
6-
/**
7-
* See https://playwright.dev/docs/test-configuration.
8-
*/
9-
export default defineConfig({
10-
testDir: "./",
11-
/* Run tests in files in parallel */
12-
fullyParallel: true,
13-
/* Fail the build on CI if you accidentally left test.only in the source code. */
14-
forbidOnly: !!process.env.CI,
15-
/* Retry on CI only */
16-
retries: process.env.CI ? 2 : 0,
17-
/* Opt out of parallel tests on CI. */
18-
workers: process.env.CI ? 1 : undefined,
19-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
20-
reporter: "html",
21-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
22-
use: {
23-
/* Base URL to use in actions like `await page.goto('/')`. */
24-
baseURL: "http://localhost:8752",
25-
26-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
27-
trace: "on-first-retry",
28-
},
29-
30-
/* Configure projects for major browsers */
31-
projects: [
32-
{
33-
name: "chromium",
34-
use: { ...devices["Desktop Chrome"] },
35-
},
36-
],
37-
38-
/* Run your local dev server before starting the tests */
39-
webServer: {
40-
command: "pnpm preview",
41-
url: "http://localhost:8752",
42-
reuseExistingServer: !process.env.CI,
43-
timeout: 500_000,
44-
},
45-
});
3+
export default configurePlaywright("gh-223", { isCI: !!process.env.CI, multipleBrowsers: false });

examples/bugs/gh-223/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"build:worker": "opennextjs-cloudflare",
11-
"dev:worker": "wrangler dev --port 8752 --inspector-port 9372",
12-
"preview": "npm run build:worker && npm run dev:worker",
11+
"preview": "npm run build:worker && npx wrangler dev",
1312
"e2e": "playwright test -c e2e/playwright.config.ts",
1413
"deploy:worker": "npm run build:worker && wrangler deploy"
1514
},

0 commit comments

Comments
 (0)