@@ -4,12 +4,10 @@ import fs from 'fs/promises'
4
4
import { join } from 'path'
5
5
import webdriver from 'next-webdriver'
6
6
import {
7
- assertHasRedbox ,
8
7
killApp ,
9
8
findPort ,
10
9
launchApp ,
11
10
retry ,
12
- getRedboxSource ,
13
11
assertNoRedbox ,
14
12
} from 'next-test-utils'
15
13
import stripAnsi from 'strip-ansi'
@@ -87,9 +85,38 @@ describe('server-side dev errors', () => {
87
85
'\n> 6 | missingVar;return {'
88
86
)
89
87
90
- await assertHasRedbox ( browser )
88
+ if ( isTurbopack ) {
89
+ await expect ( browser ) . toDisplayRedbox ( `
90
+ {
91
+ "count": 1,
92
+ "description": "ReferenceError: missingVar is not defined",
93
+ "environmentLabel": null,
94
+ "label": "Runtime Error",
95
+ "source": "../../test/integration/server-side-dev-errors/pages/gsp.js (6:3) @ getStaticProps
96
+ > 6 | missingVar;return {
97
+ | ^",
98
+ "stack": [
99
+ "getStaticProps ../../test/integration/server-side-dev-errors/pages/gsp.js (6:3)",
100
+ ],
101
+ }
102
+ ` )
103
+ } else {
104
+ await expect ( browser ) . toDisplayRedbox ( `
105
+ {
106
+ "count": 1,
107
+ "description": "ReferenceError: missingVar is not defined",
108
+ "environmentLabel": null,
109
+ "label": "Runtime Error",
110
+ "source": "pages/gsp.js (6:3) @ getStaticProps
111
+ > 6 | missingVar;return {
112
+ | ^",
113
+ "stack": [
114
+ "getStaticProps pages/gsp.js (6:3)",
115
+ ],
116
+ }
117
+ ` )
118
+ }
91
119
92
- expect ( await getRedboxSource ( browser ) ) . toContain ( 'missingVar' )
93
120
await fs . writeFile ( gspPage , content , { flush : true } )
94
121
await assertNoRedbox ( browser )
95
122
} finally {
@@ -137,9 +164,38 @@ describe('server-side dev errors', () => {
137
164
'\n> 6 | missingVar;return {'
138
165
)
139
166
140
- await assertHasRedbox ( browser )
167
+ if ( isTurbopack ) {
168
+ await expect ( browser ) . toDisplayRedbox ( `
169
+ {
170
+ "count": 1,
171
+ "description": "ReferenceError: missingVar is not defined",
172
+ "environmentLabel": null,
173
+ "label": "Runtime Error",
174
+ "source": "../../test/integration/server-side-dev-errors/pages/gssp.js (6:3) @ getServerSideProps
175
+ > 6 | missingVar;return {
176
+ | ^",
177
+ "stack": [
178
+ "getServerSideProps ../../test/integration/server-side-dev-errors/pages/gssp.js (6:3)",
179
+ ],
180
+ }
181
+ ` )
182
+ } else {
183
+ await expect ( browser ) . toDisplayRedbox ( `
184
+ {
185
+ "count": 1,
186
+ "description": "ReferenceError: missingVar is not defined",
187
+ "environmentLabel": null,
188
+ "label": "Runtime Error",
189
+ "source": "pages/gssp.js (6:3) @ getServerSideProps
190
+ > 6 | missingVar;return {
191
+ | ^",
192
+ "stack": [
193
+ "getServerSideProps pages/gssp.js (6:3)",
194
+ ],
195
+ }
196
+ ` )
197
+ }
141
198
142
- expect ( await getRedboxSource ( browser ) ) . toContain ( 'missingVar' )
143
199
await fs . writeFile ( gsspPage , content )
144
200
await assertNoRedbox ( browser )
145
201
} finally {
@@ -187,11 +243,39 @@ describe('server-side dev errors', () => {
187
243
'\n> 6 | missingVar;return {'
188
244
)
189
245
190
- await assertHasRedbox ( browser )
246
+ if ( isTurbopack ) {
247
+ await expect ( browser ) . toDisplayRedbox ( `
248
+ {
249
+ "count": 1,
250
+ "description": "ReferenceError: missingVar is not defined",
251
+ "environmentLabel": null,
252
+ "label": "Runtime Error",
253
+ "source": "../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3) @ getServerSideProps
254
+ > 6 | missingVar;return {
255
+ | ^",
256
+ "stack": [
257
+ "getServerSideProps ../../test/integration/server-side-dev-errors/pages/blog/[slug].js (6:3)",
258
+ ],
259
+ }
260
+ ` )
261
+ } else {
262
+ await expect ( browser ) . toDisplayRedbox ( `
263
+ {
264
+ "count": 1,
265
+ "description": "ReferenceError: missingVar is not defined",
266
+ "environmentLabel": null,
267
+ "label": "Runtime Error",
268
+ "source": "pages/blog/[slug].js (6:3) @ getServerSideProps
269
+ > 6 | missingVar;return {
270
+ | ^",
271
+ "stack": [
272
+ "getServerSideProps pages/blog/[slug].js (6:3)",
273
+ ],
274
+ }
275
+ ` )
276
+ }
191
277
192
- expect ( await getRedboxSource ( browser ) ) . toContain ( 'missingVar' )
193
278
await fs . writeFile ( dynamicGsspPage , content )
194
- await assertHasRedbox ( browser )
195
279
} finally {
196
280
await fs . writeFile ( dynamicGsspPage , content )
197
281
}
@@ -237,11 +321,71 @@ describe('server-side dev errors', () => {
237
321
"\n> 2 | missingVar;res.status(200).json({ hello: 'world' })"
238
322
)
239
323
240
- await assertHasRedbox ( browser )
324
+ if ( isTurbopack ) {
325
+ await expect ( browser ) . toDisplayRedbox ( `
326
+ {
327
+ "count": 1,
328
+ "description": "ReferenceError: missingVar is not defined",
329
+ "environmentLabel": null,
330
+ "label": "Runtime Error",
331
+ "source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
332
+ > 2 | missingVar;res.status(200).json({ hello: 'world' })
333
+ | ^",
334
+ "stack": [
335
+ "handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
336
+ ],
337
+ }
338
+ ` )
339
+ } else {
340
+ await expect ( browser ) . toDisplayRedbox ( `
341
+ {
342
+ "count": 1,
343
+ "description": "ReferenceError: missingVar is not defined",
344
+ "environmentLabel": null,
345
+ "label": "Runtime Error",
346
+ "source": "pages/api/hello.js (2:3) @ handler
347
+ > 2 | missingVar;res.status(200).json({ hello: 'world' })
348
+ | ^",
349
+ "stack": [
350
+ "handler pages/api/hello.js (2:3)",
351
+ ],
352
+ }
353
+ ` )
354
+ }
241
355
242
- expect ( await getRedboxSource ( browser ) ) . toContain ( 'missingVar' )
243
356
await fs . writeFile ( apiPage , content )
244
- await assertHasRedbox ( browser )
357
+
358
+ if ( isTurbopack ) {
359
+ await expect ( browser ) . toDisplayRedbox ( `
360
+ {
361
+ "count": 1,
362
+ "description": "ReferenceError: missingVar is not defined",
363
+ "environmentLabel": null,
364
+ "label": "Runtime Error",
365
+ "source": "../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3) @ handler
366
+ > 2 | missingVar;res.status(200).json({ hello: 'world' })
367
+ | ^",
368
+ "stack": [
369
+ "handler ../../test/integration/server-side-dev-errors/pages/api/hello.js (2:3)",
370
+ ],
371
+ }
372
+ ` )
373
+ } else {
374
+ await expect ( browser ) . toDisplayRedbox ( `
375
+ {
376
+ "count": 1,
377
+ "description": "ReferenceError: missingVar is not defined",
378
+ "environmentLabel": null,
379
+ "label": "Runtime Error",
380
+ "source": "pages/api/hello.js (2:3) @ handler
381
+ > 2 | missingVar;res.status(200).json({ hello: 'world' })
382
+ | ^",
383
+ "stack": [
384
+ "handler pages/api/hello.js (2:3)",
385
+ ],
386
+ }
387
+ ` )
388
+ }
245
389
} finally {
246
390
await fs . writeFile ( apiPage , content )
247
391
}
@@ -289,11 +433,71 @@ describe('server-side dev errors', () => {
289
433
'\n> 2 | missingVar;res.status(200).json({ slug: req.query.slug })'
290
434
)
291
435
292
- await assertHasRedbox ( browser )
436
+ if ( isTurbopack ) {
437
+ await expect ( browser ) . toDisplayRedbox ( `
438
+ {
439
+ "count": 1,
440
+ "description": "ReferenceError: missingVar is not defined",
441
+ "environmentLabel": null,
442
+ "label": "Runtime Error",
443
+ "source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
444
+ > 2 | missingVar;res.status(200).json({ slug: req.query.slug })
445
+ | ^",
446
+ "stack": [
447
+ "handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
448
+ ],
449
+ }
450
+ ` )
451
+ } else {
452
+ await expect ( browser ) . toDisplayRedbox ( `
453
+ {
454
+ "count": 1,
455
+ "description": "ReferenceError: missingVar is not defined",
456
+ "environmentLabel": null,
457
+ "label": "Runtime Error",
458
+ "source": "pages/api/blog/[slug].js (2:3) @ handler
459
+ > 2 | missingVar;res.status(200).json({ slug: req.query.slug })
460
+ | ^",
461
+ "stack": [
462
+ "handler pages/api/blog/[slug].js (2:3)",
463
+ ],
464
+ }
465
+ ` )
466
+ }
293
467
294
- expect ( await getRedboxSource ( browser ) ) . toContain ( 'missingVar' )
295
468
await fs . writeFile ( dynamicApiPage , content )
296
- await assertHasRedbox ( browser )
469
+
470
+ if ( isTurbopack ) {
471
+ await expect ( browser ) . toDisplayRedbox ( `
472
+ {
473
+ "count": 1,
474
+ "description": "ReferenceError: missingVar is not defined",
475
+ "environmentLabel": null,
476
+ "label": "Runtime Error",
477
+ "source": "../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3) @ handler
478
+ > 2 | missingVar;res.status(200).json({ slug: req.query.slug })
479
+ | ^",
480
+ "stack": [
481
+ "handler ../../test/integration/server-side-dev-errors/pages/api/blog/[slug].js (2:3)",
482
+ ],
483
+ }
484
+ ` )
485
+ } else {
486
+ await expect ( browser ) . toDisplayRedbox ( `
487
+ {
488
+ "count": 1,
489
+ "description": "ReferenceError: missingVar is not defined",
490
+ "environmentLabel": null,
491
+ "label": "Runtime Error",
492
+ "source": "pages/api/blog/[slug].js (2:3) @ handler
493
+ > 2 | missingVar;res.status(200).json({ slug: req.query.slug })
494
+ | ^",
495
+ "stack": [
496
+ "handler pages/api/blog/[slug].js (2:3)",
497
+ ],
498
+ }
499
+ ` )
500
+ }
297
501
} finally {
298
502
await fs . writeFile ( dynamicApiPage , content )
299
503
}
0 commit comments