8000 test(e2e): Assert that there are no funky build time warnings when bu… · alexgleason/sentry-javascript@ade4c1d · GitHub
[go: up one dir, main page]

Skip to content

Commit ade4c1d

Browse files
authored
test(e2e): Assert that there are no funky build time warnings when building Next.js apps (getsentry#9382)
1 parent ad4f2d1 commit ade4c1d

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

packages/e2e-tests/.env.example

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ E2E_TEST_AUTH_TOKEN=
22
E2E_TEST_DSN=
33
E2E_TEST_SENTRY_ORG_SLUG=
44
E2E_TEST_SENTRY_TEST_PROJECT=
5-
E2E_TEST_SHARD= # optional
6-
E2E_TEST_SHARD_AMOUNT= # optional
7-
CANARY_E2E_TEST= # optional

packages/e2e-tests/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.env
22
tmp
3-
.tmp_build_output
3+
.tmp_build_stdout
4+
.tmp_build_stderr
45
pnpm-lock.yaml
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import * as fs from 'fs';
22
import * as assert from 'assert/strict';
33

4-
const buildOutput = fs.readFileSync('.tmp_build_output', 'utf-8');
4+
const packageJson = require('./package.json');
5+
const nextjsVersion = packageJson.dependencies.next;
56

6-
// Assert that all static components stay static and all dynamic components stay dynamic
7+
const buildStdout = fs.readFileSync('.tmp_build_stdout', 'utf-8');
8+
const buildStderr = fs.readFileSync('.tmp_build_stderr', 'utf-8');
79

8-
assert.match(buildOutput, / \/client-compon 10000 ent/);
9-
assert.match(buildOutput, / \/client-component\/parameter\/\[\.\.\.parameters\]/);
10-
assert.match(buildOutput, / \/client-component\/parameter\/\[parameter\]/);
10+
// Assert that there was no funky build time warning when we are on a stable (pinned) version
11+
if (nextjsVersion !== 'latest' && nextjsVersion !== 'canary') {
12+
assert.doesNotMatch(buildStderr, /Import trace for requested module/); // This is Next.js/Webpack speech for "something is off"
13+
}
1114

12-
assert.match(buildOutput, /λ \/server-component/);
13-
assert.match(buildOutput, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/);
14-
assert.match(buildOutput, /λ \/server-component\/parameter\/\[parameter\]/);
15+
// Assert that all static components stay static and all dynamic components stay dynamic
16+
assert.match(buildStdout, / \/client-component/);
17+
assert.match(buildStdout, / \/client-component\/parameter\/\[\.\.\.parameters\]/);
18+
assert.match(buildStdout, / \/client-component\/parameter\/\[parameter\]/);
19+
assert.match(buildStdout, /λ \/server-component/);
20+
assert.match(buildStdout, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/);
21+
assert.match(buildStdout, /λ \/server-component\/parameter\/\[parameter\]/);
1522

1623
export {};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"build": "next build > .tmp_build_output",
6+
"build": "next build > .tmp_build_stdout 2> .tmp_build_stderr",
77
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
88
"test:prod": "TEST_ENV=production playwright test",
99
"test:dev": "TEST_ENV=development playwright test",
@@ -20,7 +20,7 @@
2020
"@types/node": "18.11.17",
2121
"@types/react": "18.0.26",
2222
"@types/react-dom": "18.0.9",
23-
"next": "14.0.0",
23+
"next": "14.0.2",
2424
"react": "18.2.0",
2525
"react-dom": "18.2.0",
2626
"typescript": "4.9.5",

0 commit comments

Comments
 (0)
0