Unverified Commit 9e290f9f authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Enable more hydration error overlay tests (#45404)



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 72baaebb
...@@ -15,7 +15,7 @@ createNextDescribe( ...@@ -15,7 +15,7 @@ createNextDescribe(
skipStart: true, skipStart: true,
}, },
({ next }) => { ({ next }) => {
it('should show correct hydration errror when client and server render different text', async () => { it('should show correct hydration error when client and server render different text', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -48,8 +48,8 @@ createNextDescribe( ...@@ -48,8 +48,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when client and server render different html', async () => { it.skip('should show correct hydration error when client and server render different html', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -83,8 +83,8 @@ createNextDescribe( ...@@ -83,8 +83,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when client and server render different attributes', async () => { it.skip('should show correct hydration error when client and server render different attributes', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -114,8 +114,8 @@ createNextDescribe( ...@@ -114,8 +114,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when client renders extra attributes', async () => { it.skip('should show correct hydration error when client renders extra attributes', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -146,8 +146,8 @@ createNextDescribe( ...@@ -146,8 +146,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when server renders extra attributes', async () => { it.skip('should show correct hydration error when server renders extra attributes', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -178,8 +178,8 @@ createNextDescribe( ...@@ -178,8 +178,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when both client and server render extra attributes', async () => { it.skip('should show correct hydration error when both client and server render extra attributes', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -210,8 +210,8 @@ createNextDescribe( ...@@ -210,8 +210,8 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
// TODO: does not throw error, throw to show warning in overlay or remove this test // TODO-APP: Decide if these logs should be displayed somewhere. They don't throw, just logs.
it.skip('should show correct hydration errror when client and server render different styles', async () => { it.skip('should show correct hydration error when client and server render different styles', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -243,7 +243,7 @@ createNextDescribe( ...@@ -243,7 +243,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra element as only child', async () => { it('should show correct hydration error when client renders an extra element as only child', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -276,7 +276,7 @@ createNextDescribe( ...@@ -276,7 +276,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra element in the beginning', async () => { it('should show correct hydration error when client renders an extra element in the beginning', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -311,7 +311,7 @@ createNextDescribe( ...@@ -311,7 +311,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra element in the middle', async () => { it('should show correct hydration error when client renders an extra element in the middle', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -346,7 +346,7 @@ createNextDescribe( ...@@ -346,7 +346,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra element in the end', async () => { it('should show correct hydration error when client renders an extra element in the end', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -381,7 +381,7 @@ createNextDescribe( ...@@ -381,7 +381,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra text node as only child', async () => { it('should show correct hydration error when client renders an extra text node as only child', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -410,7 +410,7 @@ createNextDescribe( ...@@ -410,7 +410,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra text node in the beginning 1', async () => { it('should show correct hydration error when client renders an extra text node in the beginning 1', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -445,7 +445,7 @@ createNextDescribe( ...@@ -445,7 +445,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra text node in the beginning 2', async () => { it('should show correct hydration error when client renders an extra text node in the beginning 2', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -480,7 +480,7 @@ createNextDescribe( ...@@ -480,7 +480,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra text node in the end', async () => { it('should show correct hydration error when client renders an extra text node in the end', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -515,7 +515,7 @@ createNextDescribe( ...@@ -515,7 +515,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra element as only child', async () => { it('should show correct hydration error when server renders an extra element as only child', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -548,7 +548,7 @@ createNextDescribe( ...@@ -548,7 +548,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra element in the beginning', async () => { it('should show correct hydration error when server renders an extra element in the beginning', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -583,7 +583,7 @@ createNextDescribe( ...@@ -583,7 +583,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra element in the middle', async () => { it('should show correct hydration error when server renders an extra element in the middle', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -618,7 +618,7 @@ createNextDescribe( ...@@ -618,7 +618,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra element in the end', async () => { it('should show correct hydration error when server renders an extra element in the end', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -653,7 +653,7 @@ createNextDescribe( ...@@ -653,7 +653,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra text node as only child', async () => { it('should show correct hydration error when server renders an extra text node as only child', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -682,7 +682,7 @@ createNextDescribe( ...@@ -682,7 +682,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra text node in the beginning', async () => { it('should show correct hydration error when server renders an extra text node in the beginning', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -717,7 +717,7 @@ createNextDescribe( ...@@ -717,7 +717,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra text node in the middle', async () => { it('should show correct hydration error when server renders an extra text node in the middle', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -752,7 +752,7 @@ createNextDescribe( ...@@ -752,7 +752,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra text node in the end', async () => { it('should show correct hydration error when server renders an extra text node in the end', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -787,7 +787,7 @@ createNextDescribe( ...@@ -787,7 +787,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when client renders an extra Suspense node in content mode', async () => { it.skip('should show correct hydration error when client renders an extra Suspense node in content mode', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -819,7 +819,7 @@ createNextDescribe( ...@@ -819,7 +819,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when server renders an extra Suspense node in content mode', async () => { it('should show correct hydration error when server renders an extra Suspense node in content mode', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -857,7 +857,7 @@ createNextDescribe( ...@@ -857,7 +857,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when client renders an extra Suspense node in fallback mode', async () => { it.skip('should show correct hydration error when client renders an extra Suspense node in fallback mode', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -882,7 +882,6 @@ createNextDescribe( ...@@ -882,7 +882,6 @@ createNextDescribe(
function Never() { function Never() {
throw new Promise((resolve) => {}) throw new Promise((resolve) => {})
} }
`, `,
], ],
]) ])
...@@ -894,7 +893,7 @@ createNextDescribe( ...@@ -894,7 +893,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when server renders an extra Suspense node in fallback mode', async () => { it.skip('should show correct hydration error when server renders an extra Suspense node in fallback mode', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -930,7 +929,7 @@ createNextDescribe( ...@@ -930,7 +929,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when client renders an extra node inside Suspense content', async () => { it('should show correct hydration error when client renders an extra node inside Suspense content', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -958,11 +957,17 @@ createNextDescribe( ...@@ -958,11 +957,17 @@ createNextDescribe(
await session.waitForAndOpenRuntimeError() await session.waitForAndOpenRuntimeError()
expect(await session.getRedboxDescription()).toMatchInlineSnapshot() expect(await session.getRedboxDescription()).toMatchInlineSnapshot(`
"Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <main> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error"
`)
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when server renders an extra node inside Suspense content', async () => { it('should show correct hydration error when server renders an extra node inside Suspense content', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -990,11 +995,17 @@ createNextDescribe( ...@@ -990,11 +995,17 @@ createNextDescribe(
await session.waitForAndOpenRuntimeError() await session.waitForAndOpenRuntimeError()
expect(await session.getRedboxDescription()).toMatchInlineSnapshot() expect(await session.getRedboxDescription()).toMatchInlineSnapshot(`
"Error: Hydration failed because the initial UI does not match what was rendered on the server.
Warning: Expected server HTML to contain a matching <footer> in <div>.
See more info here: https://nextjs.org/docs/messages/react-hydration-error"
`)
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when client renders an extra node inside Suspense fallback', async () => { it.skip('should show correct hydration error when client renders an extra node inside Suspense fallback', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -1016,7 +1027,6 @@ createNextDescribe( ...@@ -1016,7 +1027,6 @@ createNextDescribe(
} }
> >
<main className="only" /> <main className="only" />
<Never />
</React.Suspense> </React.Suspense>
</div> </div>
); );
...@@ -1033,7 +1043,7 @@ createNextDescribe( ...@@ -1033,7 +1043,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it.skip('should show correct hydration errror when server renders an extra node inside Suspense fallback', async () => { it.skip('should show correct hydration error when server renders an extra node inside Suspense fallback', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -1071,7 +1081,7 @@ createNextDescribe( ...@@ -1071,7 +1081,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra Fragment node', async () => { it('should show correct hydration error when client renders an extra Fragment node', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -1110,7 +1120,7 @@ createNextDescribe( ...@@ -1110,7 +1120,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra Fragment node', async () => { it('should show correct hydration error when server renders an extra Fragment node', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -1149,7 +1159,7 @@ createNextDescribe( ...@@ -1149,7 +1159,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when client renders an extra node deeper in the tree', async () => { it('should show correct hydration error when client renders an extra node deeper in the tree', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
...@@ -1207,7 +1217,7 @@ createNextDescribe( ...@@ -1207,7 +1217,7 @@ createNextDescribe(
await cleanup() await cleanup()
}) })
it('should show correct hydration errror when server renders an extra node deeper in the tree', async () => { it('should show correct hydration error when server renders an extra node deeper in the tree', async () => {
const { cleanup, session } = await sandbox( const { cleanup, session } = await sandbox(
next, next,
new Map([ new Map([
......
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