Skip to content
14 changes: 13 additions & 1 deletion packages/nextjs/test/integration/sentry.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import * as Sentry from '@sentry/nextjs';
Sentry.init({
dsn: 'https://[email protected]/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 }),
],
Expand Down
1 change: 0 additions & 1 deletion packages/nextjs/test/integration/test/client/errorClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
Expand Down
4 changes: 2 additions & 2 deletions packages/nextjs/test/integration/test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/test/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,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 });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL console.dir accept options in node api

}
}
};
Expand Down
5 changes: 3 additions & 2 deletions packages/nextjs/test/integration/test/utils/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
19 changes: 15 additions & 4 deletions packages/nextjs/test/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,8 +53,19 @@ 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

# we keep this updated as we run the tests, so that if it's ever non-zero, we can bail
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"
Expand All @@ -63,8 +74,8 @@ for NEXTJS_VERSION in 10 11; do
exit 1
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"
Expand Down