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,50 +434,81 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -434,50 +434,81 @@ 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()
"./index.js )
Error:
x Expected '}', got '<eof>' if (isTurbopack) {
,-[TEST_DIR/index.js:4:1] // TODO: Remove this branching once import traces are implemented in Turbopack
4 | i++ expect(redboxSource).toMatchInlineSnapshot(`
5 | throw Error('no ' + i) "./index.js:7:41
6 | }, 1000) Parsing ecmascript source code failed
7 | export default function FunctionNamed() { 5 | throw Error('no ' + i)
: ^ 6 | }, 1000)
\`---- > 7 | export default function FunctionNamed() {
| ^
Caused by:
Syntax Error Expected '}', got '<eof>'"
`)
Import trace for requested module: } else {
./index.js expect(redboxSource).toMatchInlineSnapshot(`
./pages/index.js" "./index.js
`) Error:
x Expected '}', got '<eof>'
,-[TEST_DIR/index.js:4:1]
4 | i++
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
\`----
Caused by:
Syntax Error
Import trace for requested module:
./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) {
"./index.js // TODO: Remove this branching once import traces are implemented in Turbopack
Error: expect(redboxSource).toMatchInlineSnapshot(`
x Expected '}', got '<eof>' "./index.js:7:41
,-[TEST_DIR/index.js:4:1] Parsing ecmascript source code failed
4 | i++ 5 | throw Error('no ' + i)
5 | throw Error('no ' + i) 6 | }, 1000)
6 | }, 1000) > 7 | export default function FunctionNamed() {
7 | export default function FunctionNamed() { | ^
: ^
\`---- Expected '}', got '<eof>'"
`)
Caused by: } else {
Syntax Error expect(redboxSource).toMatchInlineSnapshot(`
"./index.js
Import trace for requested module: Error:
./index.js x Expected '}', got '<eof>'
./pages/index.js" ,-[TEST_DIR/index.js:4:1]
`) 4 | i++
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
\`----
Caused by:
Syntax Error
Import trace for requested module:
./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