@@ -96,6 +96,45 @@ describe('DebugTracing', () => {
96
96
expect ( logs ) . toEqual ( [ 'log: ⚛️ Example resolved' ] ) ;
97
97
} ) ;
98
98
99
+ // @gate experimental && build === 'development' && enableDebugTracing
100
+ it ( 'should log sync render with CPU suspense' , ( ) => {
101
+ function Example ( ) {
102
+ console . log ( '<Example/>' ) ;
103
+ return null ;
104
+ }
105
+
106
+ function Wrapper ( { children} ) {
107
+ console . log ( '<Wrapper/>' ) ;
108
+ return children ;
109
+ }
110
+
111
+ ReactTestRenderer . create (
112
+ < React . unstable_DebugTracingMode >
113
+ < Wrapper >
114
+ < React . Suspense fallback = { null } unstable_expectedLoadTime = { 1 } >
115
+ < Example />
116
+ </ React . Suspense >
117
+ </ Wrapper >
118
+ </ React . unstable_DebugTracingMode > ,
119
+ ) ;
120
+
121
+ expect ( logs ) . toEqual ( [
122
+ 'group: ⚛️ render (0b0000000000000000000000000000001)' ,
123
+ 'log: <Wrapper/>' ,
124
+ 'groupEnd: ⚛️ render (0b0000000000000000000000000000001)' ,
125
+ ] ) ;
126
+
127
+ logs . splice ( 0 ) ;
128
+
129
+ expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
130
+
131
+ expect ( logs ) . toEqual ( [
132
+ 'group: ⚛️ render (0b0000010000000000000000000000000)' ,
133
+ 'log: <Example/>' ,
134
+ 'groupEnd: ⚛️ render (0b0000010000000000000000000000000)' ,
135
+ ] ) ;
136
+ } ) ;
137
+
99
138
// @gate experimental && build === 'development' && enableDebugTracing
100
139
it ( 'should log concurrent render with suspense' , async ( ) => {
101
140
const fakeSuspensePromise = Promise . resolve ( true ) ;
@@ -130,6 +169,52 @@ describe('DebugTracing', () => {
130
169
expect ( logs ) . toEqual ( [ 'log: ⚛️ Example resolved' ] ) ;
131
170
} ) ;
132
171
172
+ // @gate experimental && build === 'development' && enableDebugTracing
173
+ it ( 'should log concurrent render with CPU suspense' , ( ) => {
174
+ function Example ( ) {
175
+ console . log ( '<Example/>' ) ;
176
+ return null ;
177
+ }
178
+
179
+ function Wrapper ( { children} ) {
180
+ console . log ( '<Wrapper/>' ) ;
181
+ return children ;
182
+ }
183
+
184
+ ReactTestRenderer . create (
185
+ < React . unstable_DebugTracingMode >
186
+ < Wrapper >
187
+ < React . Suspense fallback = { null } unstable_expectedLoadTime = { 1 } >
188
+ < Example />
189
+ </ React . Suspense >
190
+ </ Wrapper >
191
+ </ React . unstable_DebugTracingMode > ,
192
+ { unstable_isConcurrent : true } ,
193
+ ) ;
194
+
195
+ expect ( logs ) . toEqual ( [ ] ) ;
196
+
197
+ logs . splice ( 0 ) ;
198
+
199
+ expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
200
+
201
+ expect ( logs ) . toEqual ( [
202
+ 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
203
+ 'log: <Wrapper/>' ,
204
+ 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
205
+ ] ) ;
206
+
207
+ logs . splice ( 0 ) ;
208
+
209
+ expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
210
+
211
+ expect ( logs ) . toEqual ( [
212
+ 'group: ⚛️ render (0b0000010000000000000000000000000)' ,
213
+ 'log: <Example/>' ,
214
+ 'groupEnd: ⚛️ render (0b0000010000000000000000000000000)' ,
215
+ ] ) ;
216
+ } ) ;
217
+
133
218
// @gate experimental && build === 'development' && enableDebugTracing
134
219
it ( 'should log cascading class component updates' , ( ) => {
135
220
class Example extends React . Component {
@@ -191,12 +276,23 @@ describe('DebugTracing', () => {
191
276
expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
192
277
} ) . toErrorDev ( 'Cannot update during an existing state transition' ) ;
193
278
194
- expect ( logs ) . toEqual ( [
195
- 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
196
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
197
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
198
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
199
- ] ) ;
279
+ gate ( flags => {
280
+ if ( flags . new ) {
281
+ expect ( logs ) . toEqual ( [
282
+ 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
283
+ 'log: ⚛️ Example updated state (0b0000000000000000000001000000000)' ,
284
+ 'log: ⚛️ Example updated state (0b0000000000000000000001000000000)' ,
285
+ 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
286
+ ] ) ;
287
+ } else {
288
+ expect ( logs ) . toEqual ( [
289
+ 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
290
+ 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
291
+ 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
292
+ 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
293
+ ] ) ;
294
+ }
295
+ } ) ;
200
296
} ) ;
201
297
202
298
// @gate experimental && build === 'development' && enableDebugTracing
@@ -274,12 +370,24 @@ describe('DebugTracing', () => {
274
370
{ unstable_isConcurrent : true } ,
275
371
) ;
276
372
} ) ;
277
- expect ( logs ) . toEqual ( [
278
- 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
279
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
280
- 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' , // debugRenderPhaseSideEffectsForStrictMode
281
- 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
282
- ] ) ;
373
+
374
+ gate ( flags => {
375
+ if ( flags . new ) {
376
+ expect ( logs ) . toEqual ( [
377
+ 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
378
+ 'log: ⚛️ Example updated state (0b0000000000000000000001000000000)' ,
379
+ 'log: ⚛️ Example updated state (0b0000000000000000000001000000000)' , // debugRenderPhaseSideEffectsForStrictMode
380
+ 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
381
+ ] ) ;
382
+ } else {
383
+ expect ( logs ) . toEqual ( [
384
+ 'group: ⚛️ render (0b0000000000000000000001000000000)' ,
385
+ 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' ,
386
+ 'log: ⚛️ Example updated state (0b0000000000000000000010000000000)' , // debugRenderPhaseSideEffectsForStrictMode
387
+ 'groupEnd: ⚛️ render (0b0000000000000000000001000000000)' ,
388
+ ] ) ;
389
+ }
390
+ } ) ;
283
391
} ) ;
284
392
285
393
// @gate experimental && build === 'development' && enableDebugTracing
0 commit comments