|
1 | 1 | /* eslint-env jest */
|
2 | 2 | import { createSandbox } from 'development-sandbox'
|
3 | 3 | import { FileRef, nextTestSetup } from 'e2e-utils'
|
4 |
| -import { check } from 'next-test-utils' |
| 4 | +import { |
| 5 | + assertHasRedbox, |
| 6 | + check, |
| 7 | + getRedboxCallStack, |
| 8 | + getRedboxDescription, |
| 9 | + getRedboxEnvironmentLabel, |
| 10 | + getRedboxSource, |
| 11 | +} from 'next-test-utils' |
5 | 12 | import path from 'path'
|
6 | 13 | import { outdent } from 'outdent'
|
7 | 14 |
|
@@ -375,20 +382,55 @@ describe('Error recovery app', () => {
|
375 | 382 | `
|
376 | 383 | )
|
377 | 384 |
|
378 |
| - await expect(browser).toDisplayRedbox(` |
379 |
| - { |
380 |
| - "description": "oops", |
381 |
| - "environmentLabel": "Server", |
382 |
| - "label": "Runtime Error", |
383 |
| - "source": "child.js (3:9) @ Child |
384 |
| - > 3 | throw new Error('oops') |
385 |
| - | ^", |
386 |
| - "stack": [ |
387 |
| - "Child child.js (3:9)", |
388 |
| - "Page app/server/page.js (3:10)", |
389 |
| - ], |
390 |
| - } |
391 |
| - `) |
| 385 | + { |
| 386 | + // FIXME: `label` is flaking between "Runtime Error" and "Recoverable Error", |
| 387 | + // so we have to snapshot the redbox manually we figure out why |
| 388 | + |
| 389 | + // await expect(browser).toDisplayRedbox(` |
| 390 | + // { |
| 391 | + // "description": "oops", |
| 392 | + // "environmentLabel": "Server", |
| 393 | + // "label": "Recoverable Error", |
| 394 | + // "source": "child.js (3:9) @ Child |
| 395 | + // > 3 | throw new Error('oops') |
| 396 | + // | ^", |
| 397 | + // "stack": [ |
| 398 | + // "Child child.js (3:9)", |
| 399 | + // "Page app/server/page.js (3:10)", |
| 400 | + // ], |
| 401 | + // } |
| 402 | + // `) |
| 403 | + |
| 404 | + await assertHasRedbox(browser) |
| 405 | + const redbox = await Promise.all([ |
| 406 | + getRedboxDescription(browser), |
| 407 | + getRedboxEnvironmentLabel(browser), |
| 408 | + getRedboxSource(browser), |
| 409 | + getRedboxCallStack(browser), |
| 410 | + ]).then(([description, environmentLabel, source, stack]) => ({ |
| 411 | + description, |
| 412 | + environmentLabel, |
| 413 | + source, |
| 414 | + stack, |
| 415 | + })) |
| 416 | + expect(redbox).toMatchInlineSnapshot(` |
| 417 | + { |
| 418 | + "description": "oops", |
| 419 | + "environmentLabel": "Server", |
| 420 | + "source": "child.js (3:9) @ Child |
| 421 | +
|
| 422 | + 1 | // hello |
| 423 | + 2 | export default function Child() { |
| 424 | + > 3 | throw new Error('oops') |
| 425 | + | ^ |
| 426 | + 4 | }", |
| 427 | + "stack": [ |
| 428 | + "Child child.js (3:9)", |
| 429 | + "Page app/server/page.js (3:10)", |
| 430 | + ], |
| 431 | + } |
| 432 | + `) |
| 433 | + } |
392 | 434 |
|
393 | 435 | // TODO-APP: re-enable when error recovery doesn't reload the page.
|
394 | 436 | /* const didNotReload = */ await session.patch(
|
@@ -580,10 +622,10 @@ describe('Error recovery app', () => {
|
580 | 622 | "description": "Parsing ecmascript source code failed",
|
581 | 623 | "environmentLabel": null,
|
582 | 624 | "label": "Build Error",
|
583 |
| - "source": "./index.js (7:41) |
| 625 | + "source": "./index.js (10:41) |
584 | 626 | Parsing ecmascript source code failed
|
585 |
| - > 7 | export default function FunctionNamed() { |
586 |
| - | ^", |
| 627 | + > 10 | export default function FunctionNamed() { |
| 628 | + | ^", |
587 | 629 | "stack": [],
|
588 | 630 | }
|
589 | 631 | `)
|
@@ -617,10 +659,10 @@ describe('Error recovery app', () => {
|
617 | 659 | "description": "Parsing ecmascript source code failed",
|
618 | 660 | "environmentLabel": null,
|
619 | 661 | "label": "Build Error",
|
620 |
| - "source": "./index.js (7:41) |
| 662 | + "source": "./index.js (10:41) |
621 | 663 | Parsing ecmascript source code failed
|
622 |
| - > 7 | export default function FunctionNamed() { |
623 |
| - | ^", |
| 664 | + > 10 | export default function FunctionNamed() { |
| 665 | + | ^", |
624 | 666 | "stack": [],
|
625 | 667 | }
|
626 | 668 | `)
|
|
0 commit comments