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