From 6075b5eba6b0278a3b5939a6a4da18c6e9a3bb23 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 15 Jan 2024 14:20:58 +0100 Subject: [PATCH 1/2] Remove normalizeSnapshot as it is no longer used --- .../acceptance-app/ReactRefreshLogBox.test.ts | 8 +++----- .../acceptance-app/rsc-build-errors.test.ts | 4 ++-- .../acceptance/ReactRefreshLogBox.test.ts | 5 +++-- test/development/acceptance/error-recovery.test.ts | 11 ++++------- test/development/basic/hmr.test.ts | 8 ++------ test/lib/next-modes/base.ts | 14 -------------- 6 files changed, 14 insertions(+), 36 deletions(-) diff --git a/test/development/acceptance-app/ReactRefreshLogBox.test.ts b/test/development/acceptance-app/ReactRefreshLogBox.test.ts index c04392e6005d4..47c9157975df6 100644 --- a/test/development/acceptance-app/ReactRefreshLogBox.test.ts +++ b/test/development/acceptance-app/ReactRefreshLogBox.test.ts @@ -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 @@ -234,7 +233,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { Unexpected eof" ` - : ` + : ` "./index.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -261,7 +260,6 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ./index.js ./app/page.js" ` - ) ) await cleanup() diff --git a/test/development/acceptance-app/rsc-build-errors.test.ts b/test/development/acceptance-app/rsc-build-errors.test.ts index b9998dea84869..c73e4abfc7f16 100644 --- a/test/development/acceptance-app/rsc-build-errors.test.ts +++ b/test/development/acceptance-app/rsc-build-errors.test.ts @@ -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: @@ -405,7 +405,7 @@ describe('Error overlay - RSC build errors', () => { // Import path: // ./app/server-with-errors/error-file/error.js" - // `)) + // `) await cleanup() }) diff --git a/test/development/acceptance/ReactRefreshLogBox.test.ts b/test/development/acceptance/ReactRefreshLogBox.test.ts index 50f45aa41fb4b..1d85125bbf96d 100644 --- a/test/development/acceptance/ReactRefreshLogBox.test.ts +++ b/test/development/acceptance/ReactRefreshLogBox.test.ts @@ -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 }) + const source = next.normalizeTestDirContent(content) if (process.env.TURBOPACK) { expect(source).toMatchInlineSnapshot(` "./index.js:7:1 diff --git a/test/development/acceptance/error-recovery.test.ts b/test/development/acceptance/error-recovery.test.ts index 899e1dffaf7da..22f991f3cabe6 100644 --- a/test/development/acceptance/error-recovery.test.ts +++ b/test/development/acceptance/error-recovery.test.ts @@ -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 '' @@ -443,7 +441,6 @@ 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)) @@ -451,7 +448,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { expect( next.normalizeTestDirContent(await session.getRedboxSource()) ).toMatchInlineSnapshot( - next.normalizeSnapshot(` + ` "./index.js Error: x Expected '}', got '' @@ -469,7 +466,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { Import trace for requested module: ./index.js ./pages/index.js" - `) + ` ) await cleanup() diff --git a/test/development/basic/hmr.test.ts b/test/development/basic/hmr.test.ts index ec7c20d1a50c4..f99e03d7de42e 100644 --- a/test/development/basic/hmr.test.ts +++ b/test/development/basic/hmr.test.ts @@ -900,7 +900,7 @@ describe.each([[''], ['/docs']])( expect( next.normalizeTestDirContent(redboxSource) ).toMatchInlineSnapshot( - next.normalizeSnapshot(` + ` "./components/parse-error.js Error: x Expression expected @@ -912,7 +912,7 @@ describe.each([[''], ['/docs']])( 4 | invalid 5 | js " - `) + ` ) await next.patchFile(aboutPage, aboutContent) @@ -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() diff --git a/test/lib/next-modes/base.ts b/test/lib/next-modes/base.ts index 5d9832d48ca4a..2ffd53e6e83ca 100644 --- a/test/lib/next-modes/base.ts +++ b/test/lib/next-modes/base.ts @@ -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 } From 29a914ab6137b60f6dafa444609d61c0e906f948 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Mon, 15 Jan 2024 15:27:30 +0100 Subject: [PATCH 2/2] Remove debug log --- test/development/acceptance/ReactRefreshLogBox.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/development/acceptance/ReactRefreshLogBox.test.ts b/test/development/acceptance/ReactRefreshLogBox.test.ts index 1d85125bbf96d..7ad05af8b7a0e 100644 --- a/test/development/acceptance/ReactRefreshLogBox.test.ts +++ b/test/development/acceptance/ReactRefreshLogBox.test.ts @@ -208,9 +208,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ) expect(await session.hasRedbox()).toBe(true) - const content = await session.getRedboxSource() - console.log({ content }) - const source = next.normalizeTestDirContent(content) + const source = next.normalizeTestDirContent(await session.getRedboxSource()) if (process.env.TURBOPACK) { expect(source).toMatchInlineSnapshot(` "./index.js:7:1