@@ -32,132 +32,147 @@ echo "Running integration tests on Node $NODE_VERSION"
3232mv next.config.js next.config.js.bak
3333
3434for NEXTJS_VERSION in 10 11 12 13; do
35+ for USE_APPDIR in true false ; do
36+ if [ " $NEXTJS_VERSION " -lt " 13" ] && [ " $USE_APPDIR " == true ]; then
37+ # Next.js < 13 do not support appDir
38+ continue
39+ fi
3540
36- # export this to the env so that we can behave differently depending on which version of next we're testing, without
37- # having to pass this value from function to function to function to the one spot, deep in some callstack, where we
38- # actually need it
39- export NEXTJS_VERSION=$NEXTJS_VERSION
40- export NODE_MAJOR=$NODE_MAJOR
41-
42- # Next 10 requires at least Node v10
43- if [ " $NODE_MAJOR " -lt " 10" ]; then
44- echo " [nextjs] Next.js is not compatible with versions of Node older than v10. Current version $NODE_VERSION "
45- exit 0
46- fi
47-
48- # Next.js v11 requires at least Node v12
49- if [ " $NODE_MAJOR " -lt " 12" ] && [ " $NEXTJS_VERSION " -ge " 11" ]; then
50- echo " [nextjs@$NEXTJS_VERSION ] Not compatible with Node $NODE_MAJOR "
51- exit 0
52- fi
53-
54- # Next.js v13 requires at least Node v14
55- if [ " $NODE_MAJOR " -lt " 14" ] && [ " $NEXTJS_VERSION " -ge " 13" ]; then
56- echo " [nextjs@$NEXTJS_VERSION ] Not compatible with Node $NODE_MAJOR "
57- exit 0
58- fi
59-
60- echo " [nextjs@$NEXTJS_VERSION ] Preparing environment..."
61- rm -rf node_modules .next .env.local 2> /dev/null || true
62-
63- echo " [nextjs@$NEXTJS_VERSION ] Installing dependencies..."
64- # set the desired version of next long enough to run yarn, and then restore the old version (doing the restoration now
65- # rather than during overall cleanup lets us look for "latest" in every loop)
66- cp package.json package.json.bak
67- if [[ $( uname) == " Darwin" ]]; then
68- sed -i " " /" next.*latest" /s/latest/" ${NEXTJS_VERSION} .x" / package.json
69- else
70- sed -i /" next.*latest" /s/latest/" ${NEXTJS_VERSION} .x" / package.json
71- fi
72-
73- # Next.js v13 requires React 18.2.0
74- if [ " $NEXTJS_VERSION " -eq " 13" ]; then
75- 76- fi
77- # We have to use `--ignore-engines` because sucrase claims to need Node 12, even though tests pass just fine on Node
78- # 10
79- yarn --no-lockfile --ignore-engines --silent > /dev/null 2>&1
80- # if applicable, use local versions of `@sentry/cli` and/or `@sentry/webpack-plugin` (these commands no-op unless
81- # LINKED_CLI_REPO and/or LINKED_PLUGIN_REPO are set)
82- linkcli && linkplugin
83- mv -f package.json.bak package.json 2> /dev/null || true
41+ # export this to the env so that we can behave differently depending on which version of next we're testing, without
42+ # having to pass this value from function to function to function to the one spot, deep in some callstack, where we
43+ # actually need it
44+ export NEXTJS_VERSION=$NEXTJS_VERSION
45+ export NODE_MAJOR=$NODE_MAJOR
46+ export USE_APPDIR=$USE_APPDIR
47+
48+ # Next 10 requires at least Node v10
49+ if [ " $NODE_MAJOR " -lt " 10" ]; then
50+ echo " [nextjs] Next.js is not compatible with versions of Node older than v10. Current version $NODE_VERSION "
51+ exit 0
52+ fi
8453
85- SHOULD_RUN_WEBPACK_5=(true)
86- # Only run Webpack 4 tests for Next 10 and Next 11
87- if [ " $NEXTJS_VERSION " -eq " 10" ] || [ " $NEXTJS_VERSION " -eq " 11" ]; then
88- SHOULD_RUN_WEBPACK_5+=(false)
89- fi
90-
91- for RUN_WEBPACK_5 in ${SHOULD_RUN_WEBPACK_5[*]} ; do
92- [ " $RUN_WEBPACK_5 " == true ] &&
93- WEBPACK_VERSION=5 ||
94- WEBPACK_VERSION=4
95-
96- if [ " $NODE_MAJOR " -gt " 17" ]; then
97- # Node v17+ does not work with NextJS 10 and 11 because of their legacy openssl use
98- # Ref: https://github.com/vercel/next.js/issues/30078
99- if [ " $NEXTJS_VERSION " -lt " 12" ]; then
100- echo " [nextjs@$NEXTJS_VERSION Node $NODE_MAJOR not compatible with NextJS $NEXTJS_VERSION "
101- # Continues the 2nd enclosing loop, which is the outer loop that iterates over the NextJS version
102- continue 2
103- fi
54+ # Next.js v11 requires at least Node v12
55+ if [ " $NODE_MAJOR " -lt " 12" ] && [ " $NEXTJS_VERSION " -ge " 11" ]; then
56+ echo " [nextjs@$NEXTJS_VERSION ] Not compatible with Node $NODE_MAJOR "
57+ exit 0
58+ fi
10459
105- # Node v18 only with Webpack 5 and above
106- # https://github.com/webpack/webpack/issues/14532#issuecomment-947513562
107- # Context: https://github.com/vercel/next.js/issues/30078#issuecomment-947338268
108- if [ " $WEBPACK_VERSION " -eq " 4" ]; then
109- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Node $NODE_MAJOR not compatible with Webpack $WEBPACK_VERSION "
110- # Continues the 1st enclosing loop, which is the inner loop that iterates over the Webpack version
111- continue
112- fi
60+ # Next.js v13 requires at least Node v14
61+ if [ " $NODE_MAJOR " -lt " 14" ] && [ " $NEXTJS_VERSION " -ge " 13" ]; then
62+ echo " [nextjs@$NEXTJS_VERSION ] Not compatible with Node $NODE_MAJOR "
63+ exit 0
64+ fi
11365
66+ echo " [nextjs@$NEXTJS_VERSION ] Preparing environment..."
67+ rm -rf node_modules .next .env.local 2> /dev/null || true
68+
69+ echo " [nextjs@$NEXTJS_VERSION ] Installing dependencies..."
70+ # set the desired version of next long enough to run yarn, and then restore the old version (doing the restoration now
71+ # rather than during overall cleanup lets us look for "latest" in every loop)
72+ cp package.json package.json.bak
73+ if [[ $( uname) == " Darwin" ]]; then
74+ sed -i " " /" next.*latest" /s/latest/" ${NEXTJS_VERSION} .x" / package.json
75+ else
76+ sed -i /" next.*latest" /s/latest/" ${NEXTJS_VERSION} .x" / package.json
11477 fi
11578
116- # next 10 defaults to webpack 4 and next 11 defaults to webpack 5, but each can use either based on settings
117- if [ " $NEXTJS_VERSION " -eq " 10" ]; then
118- sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next10.config.template > next.config.js
119- elif [ " $NEXTJS_VERSION " -eq " 11" ]; then
120- sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next11.config.template > next.config.js
121- elif [ " $NEXTJS_VERSION " -eq " 12" ]; then
122- sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next12.config.template > next.config.js
123- elif [ " $NEXTJS_VERSION " -eq " 13" ]; then
124- sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next13.config.template > next.config.js
79+ # Next.js v13 requires React 18.2.0
80+ if [ " $NEXTJS_VERSION " -eq " 13" ]; then
81+ 82+ fi
83+ # We have to use `--ignore-engines` because sucrase claims to need Node 12, even though tests pass just fine on Node
84+ # 10
85+ yarn --no-lockfile --ignore-engines --silent > /dev/null 2>&1
86+ # if applicable, use local versions of `@sentry/cli` and/or `@sentry/webpack-plugin` (these commands no-op unless
87+ # LINKED_CLI_REPO and/or LINKED_PLUGIN_REPO are set)
88+ linkcli && linkplugin
89+ mv -f package.json.bak package.json 2> /dev/null || true
90+
91+ SHOULD_RUN_WEBPACK_5=(true)
92+ # Only run Webpack 4 tests for Next 10 and Next 11
93+ if [ " $NEXTJS_VERSION " -eq " 10" ] || [ " $NEXTJS_VERSION " -eq " 11" ]; then
94+ SHOULD_RUN_WEBPACK_5+=(false)
12595 fi
12696
127- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Building..."
128- yarn build
97+ for RUN_WEBPACK_5 in ${SHOULD_RUN_WEBPACK_5[*]} ; do
98+ [ " $RUN_WEBPACK_5 " == true ] &&
99+ WEBPACK_VERSION=5 ||
100+ WEBPACK_VERSION=4
101+
102+ if [ " $NODE_MAJOR " -gt " 17" ]; then
103+ # Node v17+ does not work with NextJS 10 and 11 because of their legacy openssl use
104+ # Ref: https://github.com/vercel/next.js/issues/30078
105+ if [ " $NEXTJS_VERSION " -lt " 12" ]; then
106+ echo " [nextjs@$NEXTJS_VERSION Node $NODE_MAJOR not compatible with NextJS $NEXTJS_VERSION "
107+ # Continues the 2nd enclosing loop, which is the outer loop that iterates over the NextJS version
108+ continue 2
109+ fi
110+
111+ # Node v18 only with Webpack 5 and above
112+ # https://github.com/webpack/webpack/issues/14532#issuecomment-947513562
113+ # Context: https://github.com/vercel/next.js/issues/30078#issuecomment-947338268
114+ if [ " $WEBPACK_VERSION " -eq " 4" ]; then
115+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Node $NODE_MAJOR not compatible with Webpack $WEBPACK_VERSION "
116+ # Continues the 1st enclosing loop, which is the inner loop that iterates over the Webpack version
117+ continue
118+ fi
129119
130- # if the user hasn't passed any args, use the default one, which restricts each test to only outputting success and
131- # failure messages
132- args=$*
133- if [[ ! $args ]]; then
134- args=" --silent"
135- fi
120+ fi
136121
137- # we keep this updated as we run the tests, so that if it's ever non-zero, we can bail
138- EXIT_CODE=0
122+ # next 10 defaults to webpack 4 and next 11 defaults to webpack 5, but each can use either based on settings
123+ if [ " $NEXTJS_VERSION " -eq " 10" ]; then
124+ sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next10.config.template > next.config.js
125+ elif [ " $NEXTJS_VERSION " -eq " 11" ]; then
126+ sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next11.config.template > next.config.js
127+ elif [ " $NEXTJS_VERSION " -eq " 12" ]; then
128+ sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next12.config.template > next.config.js
129+ elif [ " $NEXTJS_VERSION " -eq " 13" ]; then
130+ if [ " $USE_APPDIR " == true ]; then
131+ sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next13.appdir.config.template > next.config.js
132+ else
133+ sed " s/%RUN_WEBPACK_5%/$RUN_WEBPACK_5 /g" < next13.config.template > next.config.js
134+ fi
135+ fi
139136
140- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Running server tests with options: $args "
141- (cd .. && yarn test:integration:server) || EXIT_CODE= $?
137+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Building... "
138+ yarn build
142139
143- if [ $EXIT_CODE -eq 0 ]; then
144- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Server integration tests passed"
145- else
146- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Server integration tests failed"
147- exit 1
148- fi
140+ # if the user hasn't passed any args, use the default one, which restricts each test to only outputting success and
141+ # failure messages
142+ args=$*
143+ if [[ ! $args ]]; then
144+ args=" --silent"
145+ fi
146+
147+ # we keep this updated as we run the tests, so that if it's ever non-zero, we can bail
148+ EXIT_CODE=0
149+
150+ if [ " $USE_APPDIR " == true ]; then
151+ echo " Skipping server tests for appdir"
152+ else
153+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Running server tests with options: $args "
154+ (cd .. && yarn test:integration:server) || EXIT_CODE=$?
155+ fi
149156
150- if [ " $NODE_MAJOR " -lt " 14" ]; then
151- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Skipping client tests on Node $NODE_MAJOR "
152- else
153- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Running client tests with options: $args "
154- (cd .. && yarn test:integration:client) || EXIT_CODE=$?
155157 if [ $EXIT_CODE -eq 0 ]; then
156- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Client integration tests passed"
158+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Server integration tests passed"
157159 else
158- echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Client integration tests failed"
160+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Server integration tests failed"
159161 exit 1
160162 fi
161- fi
163+
164+ if [ " $NODE_MAJOR " -lt " 14" ]; then
165+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Skipping client tests on Node $NODE_MAJOR "
166+ else
167+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Running client tests with options: $args "
168+ (cd .. && yarn test:integration:client) || EXIT_CODE=$?
169+ if [ $EXIT_CODE -eq 0 ]; then
170+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Client integration tests passed"
171+ else
172+ echo " [nextjs@$NEXTJS_VERSION | webpack@$WEBPACK_VERSION ] Client integration tests failed"
173+ exit 1
174+ fi
175+ fi
176+ done
162177 done
163178done
0 commit comments