@@ -123,6 +123,9 @@ describe('ReactDOMServerHydration', () => {
123
123
// Now simulate a situation where the app is not idempotent. React should
124
124
// warn but do the right thing.
125
125
element . innerHTML = lastMarkup ;
126
+ const enableClientRenderFallbackOnTextMismatch = gate (
127
+ flags => flags . enableClientRenderFallbackOnTextMismatch ,
128
+ ) ;
126
129
await expect ( async ( ) => {
127
130
root = await act ( ( ) => {
128
131
return ReactDOMClient . hydrateRoot (
@@ -139,11 +142,13 @@ describe('ReactDOMServerHydration', () => {
139
142
) ;
140
143
} ) ;
141
144
} ) . toErrorDev (
142
- [
143
- 'Text content did not match. Server: "x" Client: "y"' ,
144
- 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
145
- ] ,
146
- { withoutStack : 1 } ,
145
+ enableClientRenderFallbackOnTextMismatch
146
+ ? [
147
+ 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
148
+ 'Text content did not match. Server: "x" Client: "y"' ,
149
+ ]
150
+ : [ 'Text content did not match. Server: "x" Client: "y"' ] ,
151
+ { withoutStack : enableClientRenderFallbackOnTextMismatch ? 1 : 0 } ,
147
152
) ;
148
153
expect ( mountCount ) . toEqual ( 4 ) ;
149
154
expect ( element . innerHTML . length > 0 ) . toBe ( true ) ;
@@ -213,6 +218,9 @@ describe('ReactDOMServerHydration', () => {
213
218
const onFocusAfterHydration = jest . fn ( ) ;
214
219
element . firstChild . focus = onFocusBeforeHydration ;
215
220
221
+ const enableClientRenderFallbackOnTextMismatch = gate (
222
+ flags => flags . enableClientRenderFallbackOnTextMismatch ,
223
+ ) ;
216
224
await expect ( async ( ) => {
217
225
await act ( ( ) => {
218
226
ReactDOMClient . hydrateRoot (
@@ -224,11 +232,15 @@ describe('ReactDOMServerHydration', () => {
224
232
) ;
225
233
} ) ;
226
234
} ) . toErrorDev (
227
- [
228
- 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
229
- 'Warning: Text content did not match. Server: "server" Client: "client"' ,
230
- ] ,
231
- { withoutStack : 1 } ,
235
+ enableClientRenderFallbackOnTextMismatch
236
+ ? [
237
+ 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
238
+ 'Warning: Text content did not match. Server: "server" Client: "client"' ,
239
+ ]
240
+ : [
241
+ 'Warning: Text content did not match. Server: "server" Client: "client"' ,
242
+ ] ,
243
+ { withoutStack : enableClientRenderFallbackOnTextMismatch ? 1 : 0 } ,
232
244
) ;
233
245
234
246
expect ( onFocusBeforeHydration ) . not . toHaveBeenCalled ( ) ;
@@ -583,6 +595,9 @@ describe('ReactDOMServerHydration', () => {
583
595
) ;
584
596
domElement . innerHTML = markup ;
585
597
598
+ const enableClientRenderFallbackOnTextMismatch = gate (
599
+ flags => flags . enableClientRenderFallbackOnTextMismatch ,
600
+ ) ;
586
601
await expect ( async ( ) => {
587
602
await act ( ( ) => {
588
603
ReactDOMClient . hydrateRoot (
@@ -596,11 +611,15 @@ describe('ReactDOMServerHydration', () => {
596
611
597
612
expect ( domElement . innerHTML ) . not . toEqual ( markup ) ;
598
613
} ) . toErrorDev (
599
- [
600
- 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
601
- 'Warning: Text content did not match. Server: "server" Client: "client"' ,
602
- ] ,
603
- { withoutStack : 1 } ,
614
+ enableClientRenderFallbackOnTextMismatch
615
+ ? [
616
+ 'An error occurred during hydration. The server HTML was replaced with client content in <div>.' ,
617
+ 'Warning: Text content did not match. Server: "server" Client: "client"' ,
618
+ ]
619
+ : [
620
+ 'Warning: Text content did not match. Server: "server" Client: "client"' ,
621
+ ] ,
622
+ { withoutStack : enableClientRenderFallbackOnTextMismatch ? 1 : 0 } ,
604
623
) ;
605
624
} ) ;
606
625
0 commit comments