@@ -69,7 +69,8 @@ describe('500 Page Support', () => {
69
69
afterAll ( ( ) => killApp ( app ) )
70
70
71
71
runTests ( 'dev' )
72
-
72
+ } )
73
+ describe ( 'development mode 2' , ( ) => {
73
74
it ( 'shows error with getInitialProps in pages/500 dev' , async ( ) => {
74
75
await fs . move ( pages500 , `${ pages500 } .bak` )
75
76
await fs . writeFile (
@@ -109,123 +110,126 @@ describe('500 Page Support', () => {
109
110
afterAll ( ( ) => killApp ( app ) )
110
111
111
112
runTests ( 'server' )
112
-
113
- it ( 'does not build 500 statically with getInitialProps in _app' , async ( ) => {
114
- await fs . writeFile (
115
- pagesApp ,
116
- `
113
+ } )
114
+ ; ( process . env . TURBOPACK ? describe . skip : describe ) (
115
+ 'production mode 2' ,
116
+ ( ) => {
117
+ it ( 'does not build 500 statically with getInitialProps in _app' , async ( ) => {
118
+ await fs . writeFile (
119
+ pagesApp ,
120
+ `
117
121
import App from 'next/app'
118
122
119
123
const page = ({ Component, pageProps }) => <Component {...pageProps} />
120
124
page.getInitialProps = (ctx) => App.getInitialProps(ctx)
121
125
export default page
122
126
`
123
- )
124
- await fs . remove ( join ( appDir , '.next' ) )
125
- const {
126
- stderr,
127
- stdout : buildStdout ,
128
- code,
129
- } = await nextBuild ( appDir , [ ] , {
130
- stderr : true ,
131
- stdout : true ,
132
- } )
133
-
134
- await fs . remove ( pagesApp )
135
-
136
- expect ( stderr ) . not . toMatch ( gip500Err )
137
- expect ( buildStdout ) . not . toContain ( 'rendered 500' )
138
- expect ( code ) . toBe ( 0 )
139
- expect (
140
- await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
141
- ) . toBe ( false )
142
-
143
- let appStdout = ''
144
- const appPort = await findPort ( )
145
- const app = await nextStart ( appDir , appPort , {
146
- onStdout ( msg ) {
147
- appStdout += msg || ''
148
- } ,
149
- onStderr ( msg ) {
150
- appStdout += msg || ''
151
- } ,
152
- } )
153
-
154
- await renderViaHTTP ( appPort , '/err' )
155
- await killApp ( app )
156
-
157
- expect ( appStdout ) . toContain ( 'rendered 500' )
158
- } )
159
-
160
- it ( 'builds 500 statically by default with no pages/500' , async ( ) => {
161
- await fs . rename ( pages500 , `${ pages500 } .bak` )
162
- await fs . remove ( join ( appDir , '.next' ) )
163
- const { stderr, code } = await nextBuild ( appDir , [ ] , { stderr : true } )
164
- await fs . rename ( `${ pages500 } .bak` , pages500 )
165
-
166
- expect ( stderr ) . not . toMatch ( gip500Err )
167
- expect ( code ) . toBe ( 0 )
168
- expect (
169
- await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
170
- ) . toBe ( true )
171
-
172
- const pagesManifest = await getPagesManifest ( appDir )
173
- await updatePagesManifest (
174
- appDir ,
175
- JSON . stringify ( {
176
- ...pagesManifest ,
177
- '/500' : pagesManifest [ '/404' ] . replace ( '/404' , '/500' ) ,
127
+ )
128
+ await fs . remove ( join ( appDir , '.next' ) )
129
+ const {
130
+ stderr,
131
+ stdout : buildStdout ,
132
+ code,
133
+ } = await nextBuild ( appDir , [ ] , {
134
+ stderr : true ,
135
+ stdout : true ,
178
136
} )
179
- )
180
137
181
- // ensure static 500 hydrates correctly
182
- const appPort = await findPort ( )
183
- const app = await nextStart ( appDir , appPort )
138
+ await fs . remove ( pagesApp )
139
+
140
+ expect ( stderr ) . not . toMatch ( gip500Err )
141
+ expect ( buildStdout ) . not . toContain ( 'rendered 500' )
142
+ expect ( code ) . toBe ( 0 )
143
+ expect (
144
+ await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
145
+ ) . toBe ( false )
146
+
147
+ let appStdout = ''
148
+ const appPort = await findPort ( )
149
+ const app = await nextStart ( appDir , appPort , {
150
+ onStdout ( msg ) {
151
+ appStdout += msg || ''
152
+ } ,
153
+ onStderr ( msg ) {
154
+ appStdout += msg || ''
155
+ } ,
156
+ } )
184
157
185
- try {
186
- const browser = await webdriver ( appPort , '/err?hello=world' )
187
- const initialTitle = await browser . eval ( 'document.title' )
158
+ await renderViaHTTP ( appPort , '/err' )
159
+ await killApp ( app )
188
160
189
- const currentTitle = await browser . eval ( 'document.title' )
161
+ expect ( appStdout ) . toContain ( 'rendered 500' )
162
+ } )
190
163
191
- expect ( initialTitle ) . toBe ( currentTitle )
192
- expect ( initialTitle ) . toBe ( '500: Internal Server Error' )
193
- } finally {
194
- await killApp ( app )
195
- }
196
- } )
164
+ it ( 'builds 500 statically by default with no pages/500' , async ( ) => {
165
+ await fs . rename ( pages500 , `${ pages500 } .bak` )
166
+ await fs . remove ( join ( appDir , '.next' ) )
167
+ const { stderr, code } = await nextBuild ( appDir , [ ] , { stderr : true } )
168
+ await fs . rename ( `${ pages500 } .bak` , pages500 )
169
+
170
+ expect ( stderr ) . not . toMatch ( gip500Err )
171
+ expect ( code ) . toBe ( 0 )
172
+ expect (
173
+ await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
174
+ ) . toBe ( true )
175
+
176
+ const pagesManifest = await getPagesManifest ( appDir )
177
+ await updatePagesManifest (
178
+ appDir ,
179
+ JSON . stringify ( {
180
+ ...pagesManifest ,
181
+ '/500' : pagesManifest [ '/404' ] . replace ( '/404' , '/500' ) ,
182
+ } )
183
+ )
184
+
185
+ // ensure static 500 hydrates correctly
186
+ const appPort = await findPort ( )
187
+ const app = await nextStart ( appDir , appPort )
188
+
189
+ try {
190
+ const browser = await webdriver ( appPort , '/err?hello=world' )
191
+ const initialTitle = await browser . eval ( 'document.title' )
192
+
193
+ const currentTitle = await browser . eval ( 'document.title' )
194
+
195
+ expect ( initialTitle ) . toBe ( currentTitle )
196
+ expect ( initialTitle ) . toBe ( '500: Internal Server Error' )
197
+ } finally {
198
+ await killApp ( app )
199
+ }
200
+ } )
197
201
198
- it ( 'builds 500 statically by default with no pages/500 and custom _error without getInitialProps' , async ( ) => {
199
- await fs . rename ( pages500 , `${ pages500 } .bak` )
200
- await fs . writeFile (
201
- pagesError ,
202
- `
202
+ it ( 'builds 500 statically by default with no pages/500 and custom _error without getInitialProps' , async ( ) => {
203
+ await fs . rename ( pages500 , `${ pages500 } .bak` )
204
+ await fs . writeFile (
205
+ pagesError ,
206
+ `
203
207
function Error({ statusCode }) {
204
208
return <p>Error status: {statusCode}</p>
205
209
}
206
210
207
211
export default Error
208
212
`
209
- )
210
- await fs . remove ( join ( appDir , '.next' ) )
211
- const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
212
- stderr : true ,
213
+ )
214
+ await fs . remove ( join ( appDir , '.next' ) )
215
+ const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
216
+ stderr : true ,
217
+ } )
218
+ await fs . rename ( `${ pages500 } .bak` , pages500 )
219
+ await fs . remove ( pagesError )
220
+ console . log ( buildStderr )
221
+ expect ( buildStderr ) . not . toMatch ( gip500Err )
222
+ expect ( code ) . toBe ( 0 )
223
+ expect (
224
+ await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
225
+ ) . toBe ( true )
213
226
} )
214
- await fs . rename ( `${ pages500 } .bak` , pages500 )
215
- await fs . remove ( pagesError )
216
- console . log ( buildStderr )
217
- expect ( buildStderr ) . not . toMatch ( gip500Err )
218
- expect ( code ) . toBe ( 0 )
219
- expect (
220
- await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
221
- ) . toBe ( true )
222
- } )
223
227
224
- it ( 'does not build 500 statically with no pages/500 and custom getInitialProps in _error' , async ( ) => {
225
- await fs . rename ( pages500 , `${ pages500 } .bak` )
226
- await fs . writeFile (
227
- pagesError ,
228
- `
228
+ it ( 'does not build 500 statically with no pages/500 and custom getInitialProps in _error' , async ( ) => {
229
+ await fs . rename ( pages500 , `${ pages500 } .bak` )
230
+ await fs . writeFile (
231
+ pagesError ,
232
+ `
229
233
function Error({ statusCode }) {
230
234
return <p>Error status: {statusCode}</p>
231
235
}
@@ -244,39 +248,39 @@ describe('500 Page Support', () => {
244
248
245
249
export default Error
246
250
`
247
- )
248
- await fs . remove ( join ( appDir , '.next' ) )
249
- const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
250
- stderr : true ,
251
- } )
252
- await fs . rename ( `${ pages500 } .bak` , pages500 )
253
- await fs . remove ( pagesError )
254
- console . log ( buildStderr )
255
- expect ( buildStderr ) . not . toMatch ( gip500Err )
256
- expect ( code ) . toBe ( 0 )
257
- expect (
258
- await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
259
- ) . toBe ( false )
260
-
261
- let appStderr = ''
262
- const appPort = await findPort ( )
263
- const app = await nextStart ( appDir , appPort , {
264
- onStderr ( msg ) {
265
- appStderr += msg || ''
266
- } ,
267
- } )
251
+ )
252
+ await fs . remove ( join ( appDir , '.next' ) )
253
+ const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
254
+ stderr : true ,
255
+ } )
256
+ await fs . rename ( `${ pages500 } .bak` , pages500 )
257
+ await fs . remove ( pagesError )
258
+ console . log ( buildStderr )
259
+ expect ( buildStderr ) . not . toMatch ( gip500Err )
260
+ expect ( code ) . toBe ( 0 )
261
+ expect (
262
+ await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
263
+ ) . toBe ( false )
264
+
265
+ let appStderr = ''
266
+ const appPort = await findPort ( )
267
+ const app = await nextStart ( appDir , appPort , {
268
+ onStderr ( msg ) {
269
+ appStderr += msg || ''
270
+ } ,
271
+ } )
268
272
269
- await renderViaHTTP ( appPort , '/err' )
270
- await killApp ( app )
273
+ await renderViaHTTP ( appPort , '/err' )
274
+ await killApp ( app )
271
275
272
- expect ( appStderr ) . toContain ( 'called _error.getInitialProps' )
273
- } )
276
+ expect ( appStderr ) . toContain ( 'called _error.getInitialProps' )
277
+ } )
274
278
275
- it ( 'does not build 500 statically with no pages/500 and custom getInitialProps in _error and _app' , async ( ) => {
276
- await fs . rename ( pages500 , `${ pages500 } .bak` )
277
- await fs . writeFile (
278
- pagesError ,
279
- `
279
+ it ( 'does not build 500 statically with no pages/500 and custom getInitialProps in _error and _app' , async ( ) => {
280
+ await fs . rename ( pages500 , `${ pages500 } .bak` )
281
+ await fs . writeFile (
282
+ pagesError ,
283
+ `
280
284
function Error({ statusCode }) {
281
285
return <p>Error status: {statusCode}</p>
282
286
}
@@ -295,10 +299,10 @@ describe('500 Page Support', () => {
295
299
296
300
export default Error
297
301
`
298
- )
299
- await fs . writeFile (
300
- pagesApp ,
301
- `
302
+ )
303
+ await fs . writeFile (
304
+ pagesApp ,
305
+ `
302
306
function App({ pageProps, Component }) {
303
307
return <Component {...pageProps} />
304
308
}
@@ -316,39 +320,40 @@ describe('500 Page Support', () => {
316
320
317
321
export default App
318
322
`
319
- )
320
- await fs . remove ( join ( appDir , '.next' ) )
321
- const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
322
- stderr : true ,
323
+ )
324
+ await fs . remove ( join ( appDir , '.next' ) )
325
+ const { stderr : buildStderr , code } = await nextBuild ( appDir , [ ] , {
326
+ stderr : true ,
327
+ } )
328
+ await fs . rename ( `${ pages500 } .bak` , pages500 )
329
+ await fs . remove ( pagesError )
330
+ await fs . remove ( pagesApp )
331
+ console . log ( buildStderr )
332
+ expect ( buildStderr ) . not . toMatch ( gip500Err )
333
+ expect ( code ) . toBe ( 0 )
334
+ expect (
335
+ await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
336
+ ) . toBe ( false )
323
337
} )
324
- await fs . rename ( `${ pages500 } .bak` , pages500 )
325
- await fs . remove ( pagesError )
326
- await fs . remove ( pagesApp )
327
- console . log ( buildStderr )
328
- expect ( buildStderr ) . not . toMatch ( gip500Err )
329
- expect ( code ) . toBe ( 0 )
330
- expect (
331
- await fs . pathExists ( join ( appDir , '.next/server/pages/500.html' ) )
332
- ) . toBe ( false )
333
- } )
334
338
335
- it ( 'shows error with getInitialProps in pages/500 build' , async ( ) => {
336
- await fs . move ( pages500 , `${ pages500 } .bak` )
337
- await fs . writeFile (
338
- pages500 ,
339
- `
339
+ it ( 'shows error with getInitialProps in pages/500 build' , async ( ) => {
340
+ await fs . move ( pages500 , `${ pages500 } .bak` )
341
+ await fs . writeFile (
342
+ pages500 ,
343
+ `
340
344
const page = () => 'custom 500 page'
341
345
page.getInitialProps = () => ({ a: 'b' })
342
346
export default page
343
347
`
344
- )
345
- await fs . remove ( join ( appDir , '.next' ) )
346
- const { stderr, code } = await nextBuild ( appDir , [ ] , { stderr : true } )
347
- await fs . remove ( pages500 )
348
- await fs . move ( `${ pages500 } .bak` , pages500 )
349
-
350
- expect ( stderr ) . toMatch ( gip500Err )
351
- expect ( code ) . toBe ( 1 )
352
- } )
353
- } )
348
+ )
349
+ await fs . remove ( join ( appDir , '.next' ) )
350
+ const { stderr, code } = await nextBuild ( appDir , [ ] , { stderr : true } )
351
+ await fs . remove ( pages500 )
352
+ await fs . move ( `${ pages500 } .bak` , pages500 )
353
+
354
+ expect ( stderr ) . toMatch ( gip500Err )
355
+ expect ( code ) . toBe ( 1 )
356
+ } )
357
+ }
358
+ )
354
359
} )
0 commit comments