Skip to content

Commit

Permalink
fix snapshot between webpack and turbopack
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 27, 2024
1 parent eda7029 commit 4e7dd17
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions test/development/acceptance-app/hydration-error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { outdent } from 'outdent'
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference

describe('Error overlay for hydration errors', () => {
const { next } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
dependencies: {
react: 'latest',
Expand Down Expand Up @@ -323,15 +323,28 @@ describe('Error overlay for hydration errors', () => {
const pseudoHtml = await browser
.elementByCss('[data-nextjs-container-errors-pseudo-html] code')
.text()
expect(pseudoHtml).toMatchInlineSnapshot(`
"...
<Page>
<p>
^^^

// Turbopack currently has longer component stack trace
if (isTurbopack) {
expect(pseudoHtml).toMatchInlineSnapshot(`
"...
<Page>
<p>
^^^
<p>
^^^
"
`)
} else {
expect(pseudoHtml).toMatchInlineSnapshot(`
"<Page>
<p>
^^^
<p>
^^^
"
`)
}

await cleanup()
})
Expand Down Expand Up @@ -371,16 +384,31 @@ describe('Error overlay for hydration errors', () => {
.elementByCss('[data-nextjs-container-errors-pseudo-html] code')
.text()

expect(pseudoHtml).toMatchInlineSnapshot(`
"...
<Page>
<p>
^^^
<span>
...
<span>
// Turbopack currently has longer component stack trace
if (isTurbopack) {
expect(pseudoHtml).toMatchInlineSnapshot(`
"...
<Page>
<p>
^^^
<span>
...
<span>
"
`)
} else {
expect(pseudoHtml).toMatchInlineSnapshot(`
"<Page>
<p>
^^^
<span>
...
<span>
<p>
^^^
"
`)
}

await cleanup()
})
Expand Down

0 comments on commit 4e7dd17

Please sign in to comment.