@@ -538,53 +538,55 @@ describe('ReactDOMTracing', () => {
538
538
const root = ReactDOM . unstable_createRoot ( container ) ;
539
539
540
540
let interaction ;
541
- SchedulerTracing . unstable_trace ( 'initialization' , 0 , ( ) => {
542
- interaction = Array . from ( SchedulerTracing . unstable_getCurrent ( ) ) [ 0 ] ;
543
- // This render is only CPU bound. Nothing suspends.
544
- root . render ( < App /> ) ;
545
- } ) ;
541
+ TestUtils . act ( ( ) => {
542
+ SchedulerTracing . unstable_trace ( 'initialization' , 0 , ( ) => {
543
+ interaction = Array . from ( SchedulerTracing . unstable_getCurrent ( ) ) [ 0 ] ;
544
+ // This render is only CPU bound. Nothing suspends.
545
+ root . render ( < App /> ) ;
546
+ } ) ;
546
547
547
- expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'A' ] ) ;
548
+ expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'A' ] ) ;
548
549
549
- Scheduler . advanceTime ( 300 ) ;
550
- jest . advanceTimersByTime ( 300 ) ;
550
+ Scheduler . advanceTime ( 300 ) ;
551
+ jest . advanceTimersByTime ( 300 ) ;
551
552
552
- expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'B' ] ) ;
553
+ expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'B' ] ) ;
553
554
554
- Scheduler . advanceTime ( 300 ) ;
555
- jest . advanceTimersByTime ( 300 ) ;
555
+ Scheduler . advanceTime ( 300 ) ;
556
+ jest . advanceTimersByTime ( 300 ) ;
556
557
557
- // Time has now elapsed for so long that we're just going to give up
558
- // rendering the rest of the content. So that we can at least show
559
- // something.
560
- expect ( Scheduler ) . toFlushAndYieldThrough ( [
561
- 'Loading C' ,
562
- 'Commit A' ,
563
- 'Commit B' ,
564
- 'Commit Loading C' ,
565
- ] ) ;
558
+ // Time has now elapsed for so long that we're just going to give up
559
+ // rendering the rest of the content. So that we can at least show
560
+ // something.
561
+ expect ( Scheduler ) . toFlushAndYieldThrough ( [
562
+ 'Loading C' ,
563
+ 'Commit A' ,
564
+ 'Commit B' ,
565
+ 'Commit Loading C' ,
566
+ ] ) ;
566
567
567
- // Schedule an unrelated low priority update that shouldn't be included
568
- // in the previous interaction. This is meant to ensure that we don't
569
- // rely on the whole tree completing to cover up bugs.
570
- Scheduler . unstable_runWithPriority (
571
- Scheduler . unstable_IdlePriority ,
572
- ( ) => root . render ( < App /> ) ,
573
- ) ;
568
+ // Schedule an unrelated low priority update that shouldn't be included
569
+ // in the previous interaction. This is meant to ensure that we don't
570
+ // rely on the whole tree completing to cover up bugs.
571
+ Scheduler . unstable_runWithPriority (
572
+ Scheduler . unstable_IdlePriority ,
573
+ ( ) => root . render ( < App /> ) ,
574
+ ) ;
574
575
575
- expect ( onInteractionTraced ) . toHaveBeenCalledTimes ( 1 ) ;
576
- expect ( onInteractionTraced ) . toHaveBeenLastNotifiedOfInteraction (
577
- interaction ,
578
- ) ;
579
- expect ( onInteractionScheduledWorkCompleted ) . not . toHaveBeenCalled ( ) ;
576
+ expect ( onInteractionTraced ) . toHaveBeenCalledTimes ( 1 ) ;
577
+ expect ( onInteractionTraced ) . toHaveBeenLastNotifiedOfInteraction (
578
+ interaction ,
579
+ ) ;
580
+ expect ( onInteractionScheduledWorkCompleted ) . not . toHaveBeenCalled ( ) ;
580
581
581
- // Then we do a second pass to commit the last item.
582
- expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'C' , 'Commit C' ] ) ;
582
+ // Then we do a second pass to commit the last item.
583
+ expect ( Scheduler ) . toFlushAndYieldThrough ( [ 'C' , 'Commit C' ] ) ;
583
584
584
- expect ( onInteractionScheduledWorkCompleted ) . toHaveBeenCalledTimes ( 1 ) ;
585
- expect (
586
- onInteractionScheduledWorkCompleted ,
587
- ) . toHaveBeenLastNotifiedOfInteraction ( interaction ) ;
585
+ expect ( onInteractionScheduledWorkCompleted ) . toHaveBeenCalledTimes ( 1 ) ;
586
+ expect (
587
+ onInteractionScheduledWorkCompleted ,
588
+ ) . toHaveBeenLastNotifiedOfInteraction ( interaction ) ;
589
+ } ) ;
588
590
} ) ;
589
591
} ) ;
590
592
0 commit comments