>
>
",
"description": "Expected server HTML to contain a matching
in
.",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
},
{
"componentStack": "
>
>
",
"description": "Expected server HTML to contain a matching
in
.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
{
"description": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
]
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"componentStack": "
>
>
...",
"description": "In HTML,
cannot be a descendant of
.
This will cause a hydration error.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": "index.js (4:7) @ Page
> 4 |
Nested p tags
| ^",
"stack": [
"p ",
"Page index.js (4:7)",
],
}
`)
}
})
it('should only show one hydration error when bad nesting happened - div under p', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'index.js',
outdent`
export default function Page() {
return (
)
}
`,
],
])
)
const { browser } = sandbox
await retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(isReact18 ? 3 : 1)
})
if (isReact18) {
await expect(browser).toDisplayRedbox(`
[
{
"componentStack": "
>
>
",
"description": "Expected server HTML to contain a matching
in
.",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
},
{
"componentStack": "
>
>
",
"description": "Expected server HTML to contain a matching
in
.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
{
"description": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
]
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"componentStack": "...
>
>
...",
"description": "In HTML,
cannot be a descendant of
.
This will cause a hydration error.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": "index.js (6:11) @ Page
> 6 |
Nested div under p tag
| ^",
"stack": [
"div
",
"Page index.js (6:11)",
],
}
`)
}
})
it('should only show one hydration error when bad nesting happened - div > tr', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'index.js',
outdent`
export default function Page() {
return
}
`,
],
])
)
const { browser } = sandbox
await retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(isReact18 ? 3 : 1)
})
if (isReact18) {
await expect(browser).toDisplayRedbox(`
[
{
"componentStack": "
>
>
",
"description": "Expected server HTML to contain a matching
in .",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
},
{
"componentStack": "
>
>
",
"description": "Expected server HTML to contain a matching
in .",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
{
"description": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
]
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"componentStack": "
>
>
...",
"description": "In HTML,
cannot be a child of .
This will cause a hydration error.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": "index.js (2:15) @ Page
> 2 | return
|
| ^",
"stack": [
"tr
",
"Page index.js (2:15)",
],
}
`)
}
})
it('should show the highlighted bad nesting html snippet when bad nesting happened', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'index.js',
outdent`
export default function Page() {
return (
hello world
)
}
`,
],
])
)
const { browser } = sandbox
await retry(async () => {
expect(await getRedboxTotalErrorCount(browser)).toBe(isReact18 ? 3 : 1)
})
if (isReact18) {
await expect(browser).toDisplayRedbox(`
[
{
"componentStack": "
>
> ",
"description": "Expected server HTML to contain a matching
in .",
"environmentLabel": null,
"label": "Runtime Error",
"source": null,
"stack": [],
},
{
"componentStack": "
>
> ",
"description": "Expected server HTML to contain a matching
in .",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
{
"description": "There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": null,
"stack": [],
},
]
`)
} else {
await expect(browser).toDisplayRedbox(`
{
"componentStack": "
>
>
...",
"description": "In HTML,
cannot be a descendant of
.
This will cause a hydration error.",
"environmentLabel": null,
"label": "Recoverable Error",
"source": "index.js (3:32) @ Page
> 3 |
hello world
| ^",
"stack": [
"p ",
"Page index.js (3:32)",
],
}
`)
}
})
it('should show error if script is directly placed under html instead of body', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'pages/_document.js',
outdent`
import { Html, Head, Main, NextScript } from 'next/document'
import Script from 'next/script'
export default function Document() {
return (
)
}
`,
],
[
'index.js',
outdent`
export default function Page() {
return Hello World
}
`,
],
])
)
const { session } = sandbox
// FIXME: Should have a redbox just like with App router
await session.assertNoRedbox()
})
})