Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove normalizeSnapshot as it is no longer used #60664

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 3 additions & 5 deletions test/development/acceptance-app/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,8 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {

const source = await session.getRedboxSource()
expect(next.normalizeTestDirContent(source)).toMatchInlineSnapshot(
next.normalizeSnapshot(
IS_TURBOPACK
? `
IS_TURBOPACK
? `
"./index.js:7:1
Parsing ecmascript source code failed
5 | div
Expand All @@ -234,7 +233,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {

Unexpected eof"
`
: `
: `
"./index.js
Error:
x Unexpected token. Did you mean \`{'}'}\` or \`}\`?
Expand All @@ -261,7 +260,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
./index.js
./app/page.js"
`
)
)

await cleanup()
Expand Down
4 changes: 2 additions & 2 deletions test/development/acceptance-app/rsc-build-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ describe('Error overlay - RSC build errors', () => {

// TODO: investigate flakey snapshot due to spacing below
// expect(next.normalizeTestDirContent(await session.getRedboxSource()))
// .toMatchInlineSnapshot(next.normalizeSnapshot(`
// .toMatchInlineSnapshot(n`
// "./app/server-with-errors/error-file/error.js
// ReactServerComponentsError:

Expand All @@ -405,7 +405,7 @@ describe('Error overlay - RSC build errors', () => {

// Import path:
// ./app/server-with-errors/error-file/error.js"
// `))
// `)

await cleanup()
})
Expand Down
5 changes: 3 additions & 2 deletions test/development/acceptance/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
)

expect(await session.hasRedbox()).toBe(true)

const source = next.normalizeTestDirContent(await session.getRedboxSource())
const content = await session.getRedboxSource()
console.log({ content })
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
const source = next.normalizeTestDirContent(content)
if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(`
"./index.js:7:1
Expand Down
11 changes: 4 additions & 7 deletions test/development/acceptance/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,8 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {

await new Promise((resolve) => setTimeout(resolve, 1000))
expect(await session.hasRedbox()).toBe(true)
expect(
next.normalizeTestDirContent(await session.getRedboxSource())
).toMatchInlineSnapshot(
next.normalizeSnapshot(`
expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(`
"./index.js
Error:
x Expected '}', got '<eof>'
Expand All @@ -443,15 +441,14 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
./index.js
./pages/index.js"
`)
)

// Test that runtime error does not take over:
await new Promise((resolve) => setTimeout(resolve, 2000))
expect(await session.hasRedbox()).toBe(true)
expect(
next.normalizeTestDirContent(await session.getRedboxSource())
).toMatchInlineSnapshot(
next.normalizeSnapshot(`
`
"./index.js
Error:
x Expected '}', got '<eof>'
Expand All @@ -469,7 +466,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
Import trace for requested module:
./index.js
./pages/index.js"
`)
`
)

await cleanup()
Expand Down
8 changes: 2 additions & 6 deletions test/development/basic/hmr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ describe.each([[''], ['/docs']])(
expect(
next.normalizeTestDirContent(redboxSource)
).toMatchInlineSnapshot(
next.normalizeSnapshot(`
`
"./components/parse-error.js
Error:
x Expression expected
Expand All @@ -912,7 +912,7 @@ describe.each([[''], ['/docs']])(
4 | invalid
5 | js
"
`)
`
)

await next.patchFile(aboutPage, aboutContent)
Expand All @@ -931,10 +931,6 @@ describe.each([[''], ['/docs']])(
/This is the about page/
)
}

if (!process.env.NEXT_SWC_DEV_BIN) {
throw err
}
} finally {
if (browser) {
await browser.close()
Expand Down
14 changes: 0 additions & 14 deletions test/lib/next-modes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,6 @@ export class NextInstance {
new RegExp(escapeStringRegexp(this.testDir), 'g'),
'TEST_DIR'
)
if (process.env.NEXT_SWC_DEV_BIN) {
content = content.replace(/,----/, ',-[1:1]')
content = content.replace(/\[\.\/.*?:/, '[')
}
return content
}

// the dev binary for next-swc is missing file references
// so this normalizes to allow snapshots to match
public normalizeSnapshot(content) {
if (process.env.NEXT_SWC_DEV_BIN) {
content = content.replace(/TEST_DIR.*?:/g, '')
content = content.replace(/\[\.\/.*?:/, '[')
}
return content
}

Expand Down