Skip to content

test(nextjs): Run integration tests for Next 14 #9379

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

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"next": "10.1.3"
},
"peerDependencies": {
"next": "^10.0.8 || ^11.0 || ^12.0 || ^13.0",
"next": "^10.0.8 || ^11.0 || ^12.0 || ^13.0 || ^14.0",
"react": "16.x || 17.x || 18.x",
"webpack": ">= 4.0.0"
},
Expand Down
21 changes: 21 additions & 0 deletions packages/nextjs/test/integration/next14.config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { withSentryConfig } = require('@sentry/nextjs');

const moduleExports = {
eslint: {
ignoreDuringBuilds: true,
},
pageExtensions: ['jsx', 'js', 'tsx', 'ts', 'page.tsx'],
sentry: {
// Suppress the warning message from `handleSourcemapHidingOptionWarning` in `src/config/webpack.ts`
// TODO (v8): This can come out in v8, because this option will get a default value
hideSourceMaps: false,
excludeServerRoutes: ['/api/excludedEndpoints/excludedWithString', /\/api\/excludedEndpoints\/excludedWithRegExp/],
},
};

const SentryWebpackPluginOptions = {
dryRun: true,
silent: true,
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
14 changes: 11 additions & 3 deletions packages/nextjs/test/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "Running integration tests on Node $NODE_VERSION"
# make a backup of our config file so we can restore it when we're done
mv next.config.js next.config.js.bak

for NEXTJS_VERSION in 10 11 12 13; do
for NEXTJS_VERSION in 10 11 12 13 14; do
for USE_APPDIR in true false; do
if ([ "$NEXTJS_VERSION" -lt "13" ] || [ "$NODE_MAJOR" -lt "16" ]) && [ "$USE_APPDIR" == true ]; then
# App dir doesn not work on Next.js < 13 or Node.js < 16
Expand Down Expand Up @@ -63,6 +63,12 @@ for NEXTJS_VERSION in 10 11 12 13; do
exit 0
fi

# Next.js v14 requires at least Node v18
if [ "$NODE_MAJOR" -lt "18" ] && [ "$NEXTJS_VERSION" -ge "14" ]; then
echo "[nextjs@$NEXTJS_VERSION] Not compatible with Node $NODE_MAJOR"
exit 0
fi

echo "[nextjs@$NEXTJS_VERSION] Preparing environment..."
rm -rf node_modules .next .env.local 2>/dev/null || true

Expand All @@ -76,8 +82,8 @@ for NEXTJS_VERSION in 10 11 12 13; do
sed -i /"next.*latest"/s/latest/"${NEXTJS_VERSION}.x"/ package.json
fi

# Next.js v13 requires React 18.2.0
if [ "$NEXTJS_VERSION" -eq "13" ]; then
# Next.js v13,v14 requires React 18.2.0
if [ "$NEXTJS_VERSION" -eq "13" ] || [ "$NEXTJS_VERSION" -eq "14" ]; then
npm i --save [email protected] [email protected]
fi
# We have to use `--ignore-engines` because sucrase claims to need Node 12, even though tests pass just fine on Node
Expand Down Expand Up @@ -132,6 +138,8 @@ for NEXTJS_VERSION in 10 11 12 13; do
else
sed "s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5/g" <next13.config.template >next.config.js
fi
elif [ "$NEXTJS_VERSION" -eq "14" ]; then
sed "s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5/g" <next14.config.template >next.config.js
fi

echo "[nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION] Building..."
Expand Down