Repository: vercel/next.js
Pull request: [test] fix react 19.1 related tests

* Update hydration tests for 19.1 where we can have proper stack displayed by owner stack
* Fix version matching test for 19.0.0

Changed files:
filename: test/development/acceptance/hydration-error.test.ts
patch: @@ -11,6 +11,11 @@ describe('Error overlay for hydration errors in Pages router', () => {
   const { next } = nextTestSetup({
     files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
     skipStart: true,
+    // TODO: once Next.js minimal React version is 19.1, remove this override.
+    dependencies: {
+      react: isReact18 ? '^18.3.1' : '^19.1.0',
+      'react-dom': isReact18 ? '^18.3.1' : '^19.1.0',
+    },
   })
 
   it('includes a React docs link when hydration error does occur', async () => {
@@ -111,8 +116,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (5:9) @ Mismatch
+       > 5 |         <main className="child">{isClient ? "client" : "server"}</main>
+           |         ^",
+         "stack": [
+           "main <anonymous> (0:0)",
+           "Mismatch index.js (5:9)",
+         ],
        }
       `)
     }
@@ -193,8 +203,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (5:20) @ Mismatch
+       > 5 |       {isClient && <main className="only" />}
+           |                    ^",
+         "stack": [
+           "main <anonymous> (0:0)",
+           "Mismatch index.js (5:20)",
+         ],
        }
       `)
     }
@@ -264,8 +279,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (4:5) @ Mismatch
+       > 4 |     <div className="parent">
+           |     ^",
+         "stack": [
+           "div <anonymous> (0:0)",
+           "Mismatch index.js (4:5)",
+         ],
        }
       `)
     }
@@ -325,8 +345,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (4:5) @ Mismatch
+       > 4 |     <div className="parent">
+           |     ^",
+         "stack": [
+           "div <anonymous> (0:0)",
+           "Mismatch index.js (4:5)",
+         ],
        }
       `)
     }
@@ -384,8 +409,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (3:10) @ Mismatch
+       > 3 |   return <div className="parent">{!isClient && "only"}</div>;
+           |          ^",
+         "stack": [
+           "div <anonymous> (0:0)",
+           "Mismatch index.js (3:10)",
+         ],
        }
       `)
     }
@@ -455,8 +485,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (3:5) @ Page
+       > 3 |     <table>
+           |     ^",
+         "stack": [
+           "table <anonymous> (0:0)",
+           "Page index.js (3:5)",
+         ],
        }
       `)
     }
@@ -520,8 +555,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (3:5) @ Page
+       > 3 |     <table>
+           |     ^",
+         "stack": [
+           "table <anonymous> (0:0)",
+           "Page index.js (3:5)",
+         ],
        }
       `)
     }
@@ -593,8 +633,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
          "description": "Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (8:22) @ Mismatch
+       >  8 |         {isClient && <main className="second" />}
+            |                      ^",
+         "stack": [
+           "main <anonymous> (0:0)",
+           "Mismatch index.js (8:22)",
+         ],
        }
       `)
     }
@@ -692,8 +737,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
        This will cause a hydration error.",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (4:7) @ Page
+       > 4 |       <p>Nested p tags</p>
+           |       ^",
+         "stack": [
+           "p <anonymous> (0:0)",
+           "Page index.js (4:7)",
+         ],
        }
       `)
     }
@@ -764,8 +814,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
        This will cause a hydration error.",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (6:11) @ Page
+       > 6 |           <div>Nested div under p tag</div>
+           |           ^",
+         "stack": [
+           "div <anonymous> (0:0)",
+           "Page index.js (6:11)",
+         ],
        }
       `)
     }
@@ -826,8 +881,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
        This will cause a hydration error.",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (2:15) @ Page
+       > 2 |   return <div><tr></tr></div>
+           |               ^",
+         "stack": [
+           "tr <anonymous> (0:0)",
+           "Page index.js (2:15)",
+         ],
        }
       `)
     }
@@ -898,8 +958,13 @@ describe('Error overlay for hydration errors in Pages router', () => {
        This will cause a hydration error.",
          "environmentLabel": null,
          "label": "Runtime Error",
-         "source": null,
-         "stack": [],
+         "source": "index.js (3:32) @ Page
+       > 3 |     <p><span><span><span><span><p>hello world</p></span></span></span></span></p>
+           |                                ^",
+         "stack": [
+           "p <anonymous> (0:0)",
+           "Page index.js (3:32)",
+         ],
        }
       `)
     }

filename: test/production/custom-server/custom-server.test.ts
patch: @@ -1,8 +1,6 @@
 import { nextTestSetup } from 'e2e-utils'
 
 const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
-// TODO(new-dev-overlay): Remove this once new dev overlay is stable
-const isExperimentalReact = Boolean(process.env.__NEXT_EXPERIMENTAL_PPR)
 
 describe('custom server', () => {
   const { next } = nextTestSetup({
@@ -25,19 +23,17 @@ describe('custom server', () => {
   })
 
   describe('with app dir', () => {
-    if (!isExperimentalReact) {
-      it('should render app with react canary', async () => {
-        const $ = await next.render$(`/1`)
-        expect($('body').text()).toMatch(/app: .+-canary/)
-      })
-    }
+    it('should render app with react canary', async () => {
+      const $ = await next.render$(`/1`)
+      expect($('body').text()).toMatch(/app: .+-canary/)
+    })
 
     it('should render pages with installed react', async () => {
       const $ = await next.render$(`/2`)
       if (isReact18) {
         expect($('body').text()).toMatch(/pages: 18\.\d+\.\d+\{/)
       } else {
-        expect($('body').text()).toMatch(/pages: 19.0.0/)
+        expect($('body').text()).toMatch(/pages: 19\.\d+\.\d+/)
       }
     })
   })