Skip to content

test(e2e): Assert that there are no funky build time warnings when building Next.js apps #9382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/e2e-tests/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ E2E_TEST_AUTH_TOKEN=
E2E_TEST_DSN=
E2E_TEST_SENTRY_ORG_SLUG=
E2E_TEST_SENTRY_TEST_PROJECT=
E2E_TEST_SHARD= # optional
E2E_TEST_SHARD_AMOUNT= # optional
CANARY_E2E_TEST= # optional
3 changes: 2 additions & 1 deletion packages/e2e-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
tmp
.tmp_build_output
.tmp_build_stdout
.tmp_build_stderr
pnpm-lock.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import * as fs from 'fs';
import * as assert from 'assert/strict';

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

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

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

assert.match(buildOutput, /λ \/server-component/);
assert.match(buildOutput, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/);
assert.match(buildOutput, /λ \/server-component\/parameter\/\[parameter\]/);
// Assert that all static components stay static and all dynamic components stay dynamic
assert.match(buildStdout, /○ \/client-component/);
assert.match(buildStdout, /● \/client-component\/parameter\/\[\.\.\.parameters\]/);
assert.match(buildStdout, /● \/client-component\/parameter\/\[parameter\]/);
assert.match(buildStdout, /λ \/server-component/);
assert.match(buildStdout, /λ \/server-component\/parameter\/\[\.\.\.parameters\]/);
assert.match(buildStdout, /λ \/server-component\/parameter\/\[parameter\]/);

export {};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"build": "next build > .tmp_build_output",
"build": "next build > .tmp_build_stdout 2> .tmp_build_stderr",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:prod": "TEST_ENV=production playwright test",
"test:dev": "TEST_ENV=development playwright test",
Expand All @@ -20,7 +20,7 @@
"@types/node": "18.11.17",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.9",
"next": "14.0.0",
"next": "14.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.9.5",
Expand Down