From 576e7b1a027316a82998db352049ac7dee98159f Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 17:54:12 -0700 Subject: [PATCH 01/10] add missing import --- packages/nextjs/test/integration/test/utils/common.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/nextjs/test/integration/test/utils/common.js b/packages/nextjs/test/integration/test/utils/common.js index b831a8276f17..c818cb0e6403 100644 --- a/packages/nextjs/test/integration/test/utils/common.js +++ b/packages/nextjs/test/integration/test/utils/common.js @@ -2,6 +2,7 @@ const { createServer } = require('http'); const { parse } = require('url'); const { stat } = require('fs').promises; const next = require('next'); +const { inspect } = require('util'); const createNextServer = async config => { const app = next(config); From 5a6c8846437708349c8c8851a0a416ccc50b5e9d Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 17:54:32 -0700 Subject: [PATCH 02/10] store actual value in its own variable --- packages/nextjs/test/integration/test/utils/server.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/test/integration/test/utils/server.js b/packages/nextjs/test/integration/test/utils/server.js index d9c037a79cad..5f761317024d 100644 --- a/packages/nextjs/test/integration/test/utils/server.js +++ b/packages/nextjs/test/integration/test/utils/server.js @@ -57,13 +57,14 @@ const objectMatches = (actual, expected) => { for (const key in expected) { const expectedValue = expected[key]; + const actualValue = actual[key]; if (Object.prototype.toString.call(expectedValue) === '[object Object]' || Array.isArray(expectedValue)) { - if (!objectMatches(actual[key], expectedValue)) { + if (!objectMatches(actualValue, expectedValue)) { return false; } } else { - if (actual[key] !== expectedValue) { + if (actualValue !== expectedValue) { return false; } } From 759cca6b8ab8f49897f1134eee2fd23dc7637e20 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 17:54:55 -0700 Subject: [PATCH 03/10] add default value to `depth` help text --- packages/nextjs/test/integration/test/runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/test/integration/test/runner.js b/packages/nextjs/test/integration/test/runner.js index ae7a20e429cd..764837133864 100644 --- a/packages/nextjs/test/integration/test/runner.js +++ b/packages/nextjs/test/integration/test/runner.js @@ -21,7 +21,7 @@ const argv = yargs(process.argv.slice(2)) }) .option('depth', { type: 'number', - description: 'Set the logging depth for intercepted requests', + description: 'Set the logging depth for intercepted requests (default = 4)', }).argv; const runScenario = async (scenario, execute, env) => { From 0dbe33c839f735cc6b12b7ea2e6d66f1ff9e2d22 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 17:55:13 -0700 Subject: [PATCH 04/10] don't capture console breadcrumbs --- .../test/integration/sentry.server.config.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/test/integration/sentry.server.config.js b/packages/nextjs/test/integration/sentry.server.config.js index c8fcc45a2ae9..9df15d30523c 100644 --- a/packages/nextjs/test/integration/sentry.server.config.js +++ b/packages/nextjs/test/integration/sentry.server.config.js @@ -3,7 +3,19 @@ import * as Sentry from '@sentry/nextjs'; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', tracesSampleRate: 1, - integrations: [ + + integrations: defaults => [ + ...defaults.filter( + integration => + // filter out `Console` since the tests are happening in the console and we don't need to record what's printed + // there, because we can see it (this makes debug logging much less noisy, since intercepted events which are + // printed to the console no longer create console breadcrumbs, which then get printed, creating even longer + // console breadcrumbs, which get printed, etc, etc) + + // filter out `Http` so its options can be changed below (otherwise, default one wins because it's initialized first) + integration.name !== 'Console' && integration.name !== 'Http', + ), + // Used for testing http tracing new Sentry.Integrations.Http({ tracing: true }), ], From 1e810a002132226749bf2bb6ef3ad44d87eb82ba Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 17:57:19 -0700 Subject: [PATCH 05/10] test against correct version of nextjs --- packages/nextjs/test/run-integration-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/test/run-integration-tests.sh b/packages/nextjs/test/run-integration-tests.sh index f306825a5d97..de1a23da96f3 100755 --- a/packages/nextjs/test/run-integration-tests.sh +++ b/packages/nextjs/test/run-integration-tests.sh @@ -24,7 +24,7 @@ for NEXTJS_VERSION in 10 11; do fi # Next.js v11 requires at least Node v12 - if [ "$NODE_MAJOR" -lt "12" ] && [ "$NEXTJS_VERSION" -eq "10" ]; then + if [ "$NODE_MAJOR" -lt "12" ] && [ "$NEXTJS_VERSION" -eq "11" ]; then echo "[nextjs$NEXTJS_VERSION] Not compatible with Node $NODE_VERSION" exit 0 fi From 1c577aa3fb631d1233a19829b41297ee997a2875 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 18:04:31 -0700 Subject: [PATCH 06/10] allow test options to be passed from bash script to js test runner --- packages/nextjs/test/run-integration-tests.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/test/run-integration-tests.sh b/packages/nextjs/test/run-integration-tests.sh index de1a23da96f3..4def50a9f856 100755 --- a/packages/nextjs/test/run-integration-tests.sh +++ b/packages/nextjs/test/run-integration-tests.sh @@ -53,8 +53,18 @@ for NEXTJS_VERSION in 10 11; do echo "[nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION] Building..." yarn build | grep "Using webpack" + # if no arguments were passed, default to outputting nothing other than success and failure messages ($* gets all + # passed args as a single string) + args=$* + if [[ ! $args ]]; then + args="--silent" + fi + EXIT_CODE=0 - node test/server.js --silent || EXIT_CODE=$? + + echo "Running server tests with options: $args" + node test/server.js $args || EXIT_CODE=$? + if [ $EXIT_CODE -eq 0 ] then echo "[nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION] Server integration tests passed" @@ -64,7 +74,8 @@ for NEXTJS_VERSION in 10 11; do fi EXIT_CODE=0 - node test/client.js --silent || EXIT_CODE=$? + echo "Running client tests with options: $args" + node test/client.js $args || EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ] then echo "[nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION] Client integration tests passed" From 1f85890f637d5905c55cef85b7fd647735e1fed7 Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 12 Jul 2021 18:04:59 -0700 Subject: [PATCH 07/10] remove superfluous reset of exit code --- packages/nextjs/test/run-integration-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/test/run-integration-tests.sh b/packages/nextjs/test/run-integration-tests.sh index 4def50a9f856..fb4f186437bb 100755 --- a/packages/nextjs/test/run-integration-tests.sh +++ b/packages/nextjs/test/run-integration-tests.sh @@ -60,6 +60,7 @@ for NEXTJS_VERSION in 10 11; do args="--silent" fi + # we keep this updated as we run the tests, so that if it's ever non-zero, we can bail EXIT_CODE=0 echo "Running server tests with options: $args" @@ -73,7 +74,6 @@ for NEXTJS_VERSION in 10 11; do exit 1 fi - EXIT_CODE=0 echo "Running client tests with options: $args" node test/client.js $args || EXIT_CODE=$? if [ $EXIT_CODE -eq 0 ] From 43357e4b57a07b18d9d6ff5443a32439a229477c Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Tue, 13 Jul 2021 09:01:23 -0700 Subject: [PATCH 08/10] remove stray logging of errorClick args --- packages/nextjs/test/integration/test/client/errorClick.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nextjs/test/integration/test/client/errorClick.js b/packages/nextjs/test/integration/test/client/errorClick.js index bec43d92a25e..373729007414 100644 --- a/packages/nextjs/test/integration/test/client/errorClick.js +++ b/packages/nextjs/test/integration/test/client/errorClick.js @@ -2,7 +2,6 @@ const { waitForAll } = require('../utils/common'); const { expectRequestCount, isEventRequest, expectEvent } = require('../utils/client'); module.exports = async ({ page, url, requests }) => { - console.log(page, url, requests); await page.goto(`${url}/errorClick`); await waitForAll([page.click('button'), page.waitForRequest(isEventRequest)]); From 7290d764829b09dd75ababe372f97288e9b3b3be Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Tue, 13 Jul 2021 09:01:44 -0700 Subject: [PATCH 09/10] make test filtering case-insensitive --- packages/nextjs/test/integration/test/runner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/test/integration/test/runner.js b/packages/nextjs/test/integration/test/runner.js index 764837133864..23eba29292c2 100644 --- a/packages/nextjs/test/integration/test/runner.js +++ b/packages/nextjs/test/integration/test/runner.js @@ -66,7 +66,7 @@ module.exports.run = async ({ let scenarios = await fs.readdir(scenariosDir); if (argv.filter) { - scenarios = scenarios.filter(file => file.toLowerCase().includes(argv.filter)); + scenarios = scenarios.filter(file => file.toLowerCase().includes(argv.filter.toLowerCase())); } scenarios = scenarios.map(s => path.resolve(scenariosDir, s)); From 039dfa6a12abaf7bd33f3b85bd95ab1f6bacebcb Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Tue, 13 Jul 2021 09:03:59 -0700 Subject: [PATCH 10/10] use console.dir instead of inspect --- packages/nextjs/test/integration/test/utils/common.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/nextjs/test/integration/test/utils/common.js b/packages/nextjs/test/integration/test/utils/common.js index c818cb0e6403..f8453ce075a9 100644 --- a/packages/nextjs/test/integration/test/utils/common.js +++ b/packages/nextjs/test/integration/test/utils/common.js @@ -2,7 +2,6 @@ const { createServer } = require('http'); const { parse } = require('url'); const { stat } = require('fs').promises; const next = require('next'); -const { inspect } = require('util'); const createNextServer = async config => { const app = next(config); @@ -38,7 +37,7 @@ const logIf = (condition, message, input, depth = 4) => { if (condition) { console.log(message); if (input) { - console.log(inspect(input, { depth })); + console.dir(input, { depth, colors: true }); } } };