@@ -481,6 +481,7 @@ describe('ReactDOMServerPartialHydration', () => {
481
481
} ) ;
482
482
483
483
it ( 'recovers with client render when server rendered additional nodes at suspense root after unsuspending' , async ( ) => {
484
+ spyOnDev ( console , 'error' ) ;
484
485
const ref = React . createRef ( ) ;
485
486
function App ( { hasB} ) {
486
487
return (
@@ -526,8 +527,6 @@ describe('ReactDOMServerPartialHydration', () => {
526
527
ReactDOM . hydrateRoot ( container , < App hasB = { false } /> ) ;
527
528
} ) ;
528
529
529
- spyOnDev ( console , 'error' ) ;
530
-
531
530
resolve ( ) ;
532
531
await promise ;
533
532
Scheduler . unstable_flushAll ( ) ;
@@ -542,13 +541,20 @@ describe('ReactDOMServerPartialHydration', () => {
542
541
expect ( ref . current ) . toBe ( span ) ;
543
542
}
544
543
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 ;
547
555
expect ( errorArgs [ 0 ] ) . toBe (
548
556
'Warning: Did not expect server HTML to contain a <%s> in <%s>.%s' ,
549
557
) ;
550
- expect ( errorArgs [ 1 ] ) . toBe ( 'span' ) ;
551
- expect ( errorArgs [ 2 ] ) . toBe ( 'div' ) ;
552
558
} ) ;
553
559
554
560
it ( 'recovers with client render when server rendered additional nodes deep inside suspense root' , async ( ) => {
0 commit comments