Skip to content

Commit 54aac5c

Browse files
committed
also work for suspend then unsuspending later on client case
1 parent 3594b2b commit 54aac5c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ describe('ReactDOMServerPartialHydration', () => {
481481
});
482482

483483
it('recovers with client render when server rendered additional nodes at suspense root after unsuspending', async () => {
484+
spyOnDev(console, 'error');
484485
const ref = React.createRef();
485486
function App({hasB}) {
486487
return (
@@ -526,8 +527,6 @@ describe('ReactDOMServerPartialHydration', () => {
526527
ReactDOM.hydrateRoot(container, <App hasB={false} />);
527528
});
528529

529-
spyOnDev(console, 'error');
530-
531530
resolve();
532531
await promise;
533532
Scheduler.unstable_flushAll();
@@ -542,13 +541,20 @@ describe('ReactDOMServerPartialHydration', () => {
542541
expect(ref.current).toBe(span);
543542
}
544543

545-
expect(console.error.calls.count()).toBe(1);
546-
const errorArgs = console.error.calls.first().args;
544+
if (gate(flags => flags.enableClientRenderFallbackOnHydrationMismatch)) {
545+
expect(console.error.calls.count()).toBe(2);
546+
const errorArgs = console.error.calls.all().shift().args;
547+
expect(errorArgs[0]).toContain(
548+
'An error occurred during hydration. The server HTML was replaced with client content',
549+
);
550+
} else {
551+
expect(console.error.calls.count()).toBe(1);
552+
}
553+
554+
const errorArgs = console.error.calls.all().pop().args;
547555
expect(errorArgs[0]).toBe(
548556
'Warning: Did not expect server HTML to contain a <%s> in <%s>.%s',
549557
);
550-
expect(errorArgs[1]).toBe('span');
551-
expect(errorArgs[2]).toBe('div');
552558
});
553559

554560
it('recovers with client render when server rendered additional nodes deep inside suspense root', async () => {

0 commit comments

Comments
 (0)