Skip to content
Merged
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
94 changes: 81 additions & 13 deletions test/development/acceptance-app/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { check } from 'next-test-utils'
import path from 'path'
import { outdent } from 'outdent'

const isRspack = !!process.env.NEXT_RSPACK

describe('Error recovery app', () => {
const { next, isTurbopack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
Expand Down Expand Up @@ -53,6 +55,28 @@ describe('Error recovery app', () => {
"stack": [],
}
`)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js
× Module build failed:
╰─▶ × Error: x Unexpected eof
│ ,----
│ 1 | export default () => <div/
│ \`----
│ Caused by:
│ Syntax Error
Import trace for requested module:
./index.js
./app/page.js",
"stack": [],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
Expand Down Expand Up @@ -547,19 +571,35 @@ describe('Error recovery app', () => {
)

await browser.eval('window.triggerError()')
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "no 1",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (7:11) @ eval
> 7 | throw Error('no ' + i)
| ^",
"stack": [
"eval index.js (7:11)",
],
}
`)
if (isRspack) {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "no 1",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (7:11) @ eval
> 7 | throw Error('no ' + i)
| ^",
"stack": [
"eval index.js (7:11)",
],
}
`)
} else {
await expect(browser).toDisplayCollapsedRedbox(`
{
"description": "no 1",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (7:11) @ eval
> 7 | throw Error('no ' + i)
| ^",
"stack": [
"eval index.js (7:11)",
],
}
`)
}

// Make a syntax error.
await session.patch(
Expand Down Expand Up @@ -802,6 +842,34 @@ describe('Error recovery app', () => {
"stack": [],
}
`)
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
"environmentLabel": null,
"label": "Build Error",
"source": "./index.js
× Module build failed:
╰─▶ × Error: x Expected '{', got 'return'
│ ,-[5:1]
│ 2 |
│ 3 | class ClassDefault extends React.Component {
│ 4 | render()
│ 5 | return <h1>Default Export</h1>;
│ : ^^^^^^
│ 6 | }
│ 7 | }
│ \`----
│ Caused by:
│ Syntax Error
Import trace for requested module:
./index.js
./app/page.js",
"stack": [],
}
`)
} else {
await expect(browser).toDisplayRedbox(`
{
Expand Down
19 changes: 10 additions & 9 deletions test/development/acceptance/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { outdent } from 'outdent'
import path from 'path'

const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
const isRspack = !!process.env.NEXT_RSPACK

describe('pages/ error recovery', () => {
const { next, isTurbopack } = nextTestSetup({
Expand Down Expand Up @@ -55,7 +56,7 @@ describe('pages/ error recovery', () => {
"stack": [],
}
`)
} else if (process.env.NEXT_RSPACK) {
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
Expand Down Expand Up @@ -369,7 +370,7 @@ describe('pages/ error recovery', () => {
"stack": [],
}
`)
} else if (process.env.NEXT_RSPACK) {
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
Expand Down Expand Up @@ -454,7 +455,7 @@ describe('pages/ error recovery', () => {
"stack": [],
}
`)
} else if (process.env.NEXT_RSPACK) {
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
Expand Down Expand Up @@ -570,7 +571,7 @@ describe('pages/ error recovery', () => {
]
`)
} else {
if (process.env.NEXT_RSPACK) {
if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "nooo",
Expand Down Expand Up @@ -752,17 +753,17 @@ describe('pages/ error recovery', () => {
)
await new Promise((resolve) => setTimeout(resolve, 1000))

if (process.env.NEXT_RSPACK) {
if (isRspack) {
await expect(browser).toDisplayRedbox(`
{
"description": "no 1",
"environmentLabel": null,
"label": "Runtime Error",
"source": "index.js (5:9) @ <unknown>
"source": "index.js (5:9) @ eval
> 5 | throw Error('no ' + i)
| ^",
"stack": [
"<unknown> index.js (5:9)",
"eval index.js (5:9)",
],
}
`)
Expand Down Expand Up @@ -812,7 +813,7 @@ describe('pages/ error recovery', () => {
"stack": [],
}
`)
} else if (process.env.NEXT_RSPACK) {
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
Expand Down Expand Up @@ -880,7 +881,7 @@ describe('pages/ error recovery', () => {
"stack": [],
}
`)
} else if (process.env.NEXT_RSPACK) {
} else if (isRspack) {
await expect({ browser, next }).toDisplayRedbox(`
{
"description": " × Module build failed:",
Expand Down