Unverified Commit f96ec515 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack HMR: use own snapshot in error-recovery (#63417)

This records dedicated snapshots for Turbopack for the remaining tests
in `test/development/acceptance/error-recovery.test.ts`. The only
remaining difference was the lack of Import trace information.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/acceptance/error-recovery.test.ts`


Closes PACK-2761
parent 51b878f5
...@@ -11,3 +11,15 @@ exports[`ReactRefreshLogBox default syntax > runtime error 1`] = ` ...@@ -11,3 +11,15 @@ exports[`ReactRefreshLogBox default syntax > runtime error 1`] = `
7 | export default function FunctionNamed() { 7 | export default function FunctionNamed() {
8 | return <div />" 8 | return <div />"
`; `;
exports[`ReactRefreshLogBox turbo syntax > runtime error 1`] = `
"index.js (5:9) @ eval
3 | setInterval(() => {
4 | i++
> 5 | throw Error('no ' + i)
| ^
6 | }, 1000)
7 | export default function FunctionNamed() {
8 | return <div />"
`;
...@@ -434,8 +434,24 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -434,8 +434,24 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
await new Promise((resolve) => setTimeout(resolve, 1000)) await new Promise((resolve) => setTimeout(resolve, 1000))
expect(await session.hasRedbox()).toBe(true) expect(await session.hasRedbox()).toBe(true)
expect(next.normalizeTestDirContent(await session.getRedboxSource())) let redboxSource = next.normalizeTestDirContent(
.toMatchInlineSnapshot(` await session.getRedboxSource()
)
if (isTurbopack) {
// TODO: Remove this branching once import traces are implemented in Turbopack
expect(redboxSource).toMatchInlineSnapshot(`
"./index.js:7:41
Parsing ecmascript source code failed
5 | throw Error('no ' + i)
6 | }, 1000)
> 7 | export default function FunctionNamed() {
| ^
Expected '}', got '<eof>'"
`)
} else {
expect(redboxSource).toMatchInlineSnapshot(`
"./index.js "./index.js
Error: Error:
x Expected '}', got '<eof>' x Expected '}', got '<eof>'
...@@ -454,12 +470,26 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -454,12 +470,26 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
./index.js ./index.js
./pages/index.js" ./pages/index.js"
`) `)
}
// Test that runtime error does not take over: // Test that runtime error does not take over:
await new Promise((resolve) => setTimeout(resolve, 2000)) await new Promise((resolve) => setTimeout(resolve, 2000))
expect(await session.hasRedbox()).toBe(true) expect(await session.hasRedbox()).toBe(true)
expect(next.normalizeTestDirContent(await session.getRedboxSource())) redboxSource = next.normalizeTestDirContent(await session.getRedboxSource())
.toMatchInlineSnapshot(` if (isTurbopack) {
// TODO: Remove this branching once import traces are implemented in Turbopack
expect(redboxSource).toMatchInlineSnapshot(`
"./index.js:7:41
Parsing ecmascript source code failed
5 | throw Error('no ' + i)
6 | }, 1000)
> 7 | export default function FunctionNamed() {
| ^
Expected '}', got '<eof>'"
`)
} else {
expect(redboxSource).toMatchInlineSnapshot(`
"./index.js "./index.js
Error: Error:
x Expected '}', got '<eof>' x Expected '}', got '<eof>'
...@@ -478,6 +508,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -478,6 +508,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
./index.js ./index.js
./pages/index.js" ./pages/index.js"
`) `)
}
await cleanup() await cleanup()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment