@@ -7,12 +7,49 @@ import { getRedboxTotalErrorCount } from 'next-test-utils'
7
7
8
8
// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
9
9
10
- describe ( 'Error overlay for hydration errors' , ( ) => {
10
+ describe ( 'Error overlay for hydration errors in App router ' , ( ) => {
11
11
const { next, isTurbopack } = nextTestSetup ( {
12
12
files : new FileRef ( path . join ( __dirname , 'fixtures' , 'default-template' ) ) ,
13
13
skipStart : true ,
14
14
} )
15
15
16
+ it ( 'includes a React docs link when hydration error does occur' , async ( ) => {
17
+ const { browser } = await sandbox (
18
+ next ,
19
+ new Map ( [
20
+ [
21
+ 'app/page.js' ,
22
+ outdent `
23
+ 'use client'
24
+ const isClient = typeof window !== 'undefined'
25
+ export default function Mismatch() {
26
+ return (
27
+ <div className="parent">
28
+ <main className="child">{isClient ? "client" : "server"}</main>
29
+ </div>
30
+ );
31
+ }
32
+ ` ,
33
+ ] ,
34
+ ] ) ,
35
+ '/' ,
36
+ { pushErrorAsConsoleLog : true }
37
+ )
38
+
39
+ const logs = await browser . log ( )
40
+ expect ( logs ) . toEqual (
41
+ expect . arrayContaining ( [
42
+ {
43
+ // TODO: Should probably link to https://nextjs.org/docs/messages/react-hydration-error instead.
44
+ message : expect . stringContaining (
45
+ 'https://react.dev/link/hydration-mismatch'
46
+ ) ,
47
+ source : 'error' ,
48
+ } ,
49
+ ] )
50
+ )
51
+ } )
52
+
16
53
it ( 'should show correct hydration error when client and server render different text' , async ( ) => {
17
54
const { cleanup, session, browser } = await sandbox (
18
55
next ,
0 commit comments