Skip to content

Commit 5169c2f

Browse files
authored
test(e2e): Avoid race condition with event proxy (#7965)
1 parent 54d588e commit 5169c2f

File tree

15 files changed

+31
-26
lines changed

15 files changed

+31
-26
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ jobs:
770770
ref: ${{ env.HEAD_COMMIT }}
771771
- uses: pnpm/action-setup@v2
772772
with:
773-
version: 7
773+
version: 8.3.1
774774
- name: Set up Node
775775
uses: actions/setup-node@v3
776776
with:

.github/workflows/canary.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
ref: ${{ env.HEAD_COMMIT }}
2929
- uses: pnpm/action-setup@v2
3030
with:
31-
version: 7
31+
version: 8.3.1
3232
- name: Set up Node
3333
uses: actions/setup-node@v3
3434
with:

packages/e2e-tests/lib/runTestApp.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export async function buildAndTestApp(
1616

1717
const tmpFolder = path.join(__dirname, '..', 'tmp');
1818
await fs.promises.mkdir(tmpFolder, { recursive: true });
19-
const targetDir = await fs.promises.mkdtemp(path.join(tmpFolder, 'tmp-app-'));
19+
const targetDir = await fs.promises.mkdtemp(
20+
path.join(tmpFolder, `${recipeInstance.recipe.testApplicationName}-${Date.now()}-`),
21+
);
2022

2123
await fsExtra.copy(recipeDirname, targetDir);
2224

packages/e2e-tests/test-applications/create-next-app/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const config: PlaywrightTestConfig = {
6767

6868
/* Run your local dev server before starting the tests */
6969
webServer: {
70-
command: testEnv === 'development' ? `yarn next dev -p ${port}` : `yarn next start -p ${port}`,
70+
command: testEnv === 'development' ? `pnpm next dev -p ${port}` : `pnpm next start -p ${port}`,
7171
port,
7272
},
7373
};

packages/e2e-tests/test-applications/create-next-app/test-recipe.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
"tests": [
66
{
77
"testName": "Playwright tests - Prod Mode",
8-
"testCommand": "yarn test:prod"
8+
"testCommand": "pnpm test:prod"
99
},
1010
{
1111
"testName": "Playwright tests - Dev Mode",
12-
"testCommand": "yarn test:dev"
12+
"testCommand": "pnpm test:dev"
1313
}
1414
]
1515
}

packages/e2e-tests/test-applications/nextjs-app-dir/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
"next": "13.2.4",
1717
"react": "18.2.0",
1818
"react-dom": "18.2.0",
19-
"typescript": "4.9.4"
20-
},
21-
"devDependencies": {
19+
"typescript": "4.9.4",
20+
"wait-port": "1.0.4",
2221
"ts-node": "10.9.1",
2322
"@playwright/test": "^1.27.1"
2423
},

packages/e2e-tests/test-applications/nextjs-app-dir/playwright.config.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ if (!testEnv) {
77
throw new Error('No test env defined');
88
}
99

10-
const port = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO);
10+
const nextPort = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO);
11+
const eventProxyPort = Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP);
1112

1213
/**
1314
* See https://playwright.dev/docs/test-configuration.
@@ -36,7 +37,7 @@ const config: PlaywrightTestConfig = {
3637
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
3738
actionTimeout: 0,
3839
/* Base URL to use in actions like `await page.goto('/')`. */
39-
baseURL: `http://localhost:${port}`,
40+
baseURL: `http://localhost:${nextPort}`,
4041

4142
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4243
trace: 'on-first-retry',
@@ -55,12 +56,15 @@ const config: PlaywrightTestConfig = {
5556
/* Run your local dev server before starting the tests */
5657
webServer: [
5758
{
58-
command: testEnv === 'development' ? `yarn next dev -p ${port}` : `yarn next start -p ${port}`,
59-
port,
59+
command: 'pnpm ts-node-script start-event-proxy.ts',
60+
port: eventProxyPort,
6061
},
6162
{
62-
command: 'yarn ts-node-script start-event-proxy.ts',
63-
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO) + Number(process.env.PORT_GAP),
63+
command:
64+
testEnv === 'development'
65+
? `pnpm wait-port ${eventProxyPort} && pnpm next dev -p ${nextPort}`
66+
: `pnpm wait-port ${eventProxyPort} && pnpm next start -p ${nextPort}`,
67+
port: nextPort,
6468
},
6569
],
6670
};

packages/e2e-tests/test-applications/nextjs-app-dir/test-recipe.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"$schema": "../../test-recipe-schema.json",
33
"testApplicationName": "nextjs-13-app-dir",
44
"buildCommand": "pnpm install && npx playwright install && pnpm build",
5-
"buildAssertionCommand": "yarn ts-node --script-mode assert-build.ts",
5+
"buildAssertionCommand": "pnpm ts-node --script-mode assert-build.ts",
66
"tests": [
77
{
88
"testName": "Prod Mode",
9-
"testCommand": "yarn test:prod"
9+
"testCommand": "pnpm test:prod"
1010
},
1111
{
1212
"testName": "Dev Mode",
13-
"testCommand": "yarn test:dev"
13+
"testCommand": "pnpm test:dev"
1414
}
1515
],
1616
"canaryVersions": [

packages/e2e-tests/test-applications/node-express-app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "yarn tsc",
6+
"build": "tsc",
77
"start": "node dist/app.js",
8-
"test": "yarn playwright test"
8+
"test": "playwright test"
99
},
1010
"dependencies": {
1111
"@sentry/integrations": "*",

packages/e2e-tests/test-applications/node-express-app/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const config: PlaywrightTestConfig = {
5757

5858
/* Run your local dev server before starting the tests */
5959
webServer: {
60-
command: 'yarn start',
60+
command: 'pnpm start',
6161
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO),
6262
},
6363
};

packages/e2e-tests/test-applications/node-express-app/test-recipe.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tests": [
66
{
77
"testName": "Test express server",
8-
"testCommand": "yarn test",
8+
"testCommand": "pnpm test",
99
"timeoutSeconds": 60
1010
}
1111
]

packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const config: PlaywrightTestConfig = {
5959

6060
/* Run your local dev server before starting the tests */
6161
webServer: {
62-
command: 'yarn start',
62+
command: 'pnpm start',
6363
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO),
6464
env: {
6565
PORT: String(Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO)),

packages/e2e-tests/test-applications/standard-frontend-react-tracing-import/test-recipe.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tests": [
66
{
77
"testName": "Playwright tests",
8-
"testCommand": "yarn test"
8+
"testCommand": "pnpm test"
99
}
1010
],
1111
"canaryVersions": []

packages/e2e-tests/test-applications/standard-frontend-react/playwright.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const config: PlaywrightTestConfig = {
5959

6060
/* Run your local dev server before starting the tests */
6161
webServer: {
62-
command: 'yarn start',
62+
command: 'pnpm start',
6363
port: Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO),
6464
env: {
6565
PORT: String(Number(process.env.BASE_PORT) + Number(process.env.PORT_MODULO)),

packages/e2e-tests/test-applications/standard-frontend-react/test-recipe.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tests": [
66
{
77
"testName": "Playwright tests",
8-
"testCommand": "yarn test"
8+
"testCommand": "pnpm test"
99
}
1010
],
1111
"canaryVersions": [

0 commit comments

Comments
 (0)