@@ -584,6 +584,7 @@ describe('ReactErrorBoundaries', () => {
584
584
} ) ;
585
585
} ) . rejects . toThrow ( 'Hello' ) ;
586
586
587
+ Scheduler . unstable_clearLog ( ) ;
587
588
container = document . createElement ( 'div' ) ;
588
589
root = ReactDOMClient . createRoot ( container ) ;
589
590
await expect ( async ( ) => {
@@ -592,6 +593,7 @@ describe('ReactErrorBoundaries', () => {
592
593
} ) ;
593
594
} ) . rejects . toThrow ( 'Hello' ) ;
594
595
596
+ Scheduler . unstable_clearLog ( ) ;
595
597
container = document . createElement ( 'div' ) ;
596
598
root = ReactDOMClient . createRoot ( container ) ;
597
599
await expect ( async ( ) => {
@@ -607,28 +609,32 @@ describe('ReactErrorBoundaries', () => {
607
609
await act ( async ( ) => {
608
610
root . render ( < BrokenComponentWillUpdate /> ) ;
609
611
} ) ;
612
+ Scheduler . unstable_clearLog ( ) ;
610
613
await expect ( async ( ) => {
611
614
await act ( async ( ) => {
612
615
root . render ( < BrokenComponentWillUpdate /> ) ;
613
616
} ) ;
614
617
} ) . rejects . toThrow ( 'Hello' ) ;
615
618
619
+ Scheduler . unstable_clearLog ( ) ;
616
620
container = document . createElement ( 'div' ) ;
617
621
root = ReactDOMClient . createRoot ( container ) ;
618
622
await act ( async ( ) => {
619
623
root . render ( < BrokenComponentWillReceiveProps /> ) ;
620
624
} ) ;
625
+ Scheduler . unstable_clearLog ( ) ;
621
626
await expect ( async ( ) => {
622
627
await act ( async ( ) => {
623
628
root . render ( < BrokenComponentWillReceiveProps /> ) ;
624
629
} ) ;
625
630
} ) . rejects . toThrow ( 'Hello' ) ;
626
-
631
+ Scheduler . unstable_clearLog ( ) ;
627
632
container = document . createElement ( 'div' ) ;
628
633
root = ReactDOMClient . createRoot ( container ) ;
629
634
await act ( async ( ) => {
630
635
root . render ( < BrokenComponentDidUpdate /> ) ;
631
636
} ) ;
637
+ Scheduler . unstable_clearLog ( ) ;
632
638
await expect ( async ( ) => {
633
639
await act ( async ( ) => {
634
640
root . render ( < BrokenComponentDidUpdate /> ) ;
@@ -642,6 +648,7 @@ describe('ReactErrorBoundaries', () => {
642
648
await act ( async ( ) => {
643
649
root . render ( < BrokenComponentWillUnmount /> ) ;
644
650
} ) ;
651
+ Scheduler . unstable_clearLog ( ) ;
645
652
await expect ( async ( ) => {
646
653
await act ( ( ) => root . unmount ( ) ) ;
647
654
} ) . rejects . toThrow ( 'Hello' ) ;
@@ -663,6 +670,15 @@ describe('ReactErrorBoundaries', () => {
663
670
root2 . render ( < BrokenRender /> ) ;
664
671
} ) ;
665
672
} ) . rejects . toThrow ( 'Hello' ) ;
673
+
674
+ assertLog ( [
675
+ 'BrokenRender constructor' ,
676
+ 'BrokenRender componentWillMount' ,
677
+ 'BrokenRender render [!]' ,
678
+ 'BrokenRender constructor' ,
679
+ 'BrokenRender componentWillMount' ,
680
+ 'BrokenRender render [!]' ,
681
+ ] ) ;
666
682
await act ( async ( ) => {
667
683
root3 . render (
668
684
< ErrorBoundary >
@@ -674,12 +690,15 @@ describe('ReactErrorBoundaries', () => {
674
690
expect ( container2 . firstChild ) . toBe ( null ) ;
675
691
expect ( container3 . firstChild . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
676
692
693
+ Scheduler . unstable_clearLog ( ) ;
677
694
await act ( async ( ) => {
678
695
root1 . render ( < span > After 1</ span > ) ;
679
696
} ) ;
697
+ Scheduler . unstable_clearLog ( ) ;
680
698
await act ( async ( ) => {
681
699
root2 . render ( < span > After 2</ span > ) ;
682
700
} ) ;
701
+ Scheduler . unstable_clearLog ( ) ;
683
702
await act ( async ( ) => {
684
703
root3 . render ( < ErrorBoundary forceRetry = { true } > After 3</ ErrorBoundary > ) ;
685
704
} ) ;
@@ -1828,6 +1847,7 @@ describe('ReactErrorBoundaries', () => {
1828
1847
) ;
1829
1848
} ) ;
1830
1849
1850
+ Scheduler . unstable_clearLog ( ) ;
1831
1851
await act ( async ( ) => {
1832
1852
root . render (
1833
1853
< ErrorBoundary >
@@ -1879,6 +1899,7 @@ describe('ReactErrorBoundaries', () => {
1879
1899
) ;
1880
1900
} ) ;
1881
1901
expect ( container . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
1902
+ Scheduler . unstable_clearLog ( ) ;
1882
1903
1883
1904
await act ( async ( ) => {
1884
1905
root . render (
@@ -1888,6 +1909,7 @@ describe('ReactErrorBoundaries', () => {
1888
1909
) ;
1889
1910
} ) ;
1890
1911
expect ( container . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
1912
+ Scheduler . unstable_clearLog ( ) ;
1891
1913
1892
1914
await act ( async ( ) => {
1893
1915
root . render ( < div > Other screen</ div > ) ;
@@ -1909,7 +1931,7 @@ describe('ReactErrorBoundaries', () => {
1909
1931
</ ErrorBoundary > ,
1910
1932
) ;
1911
1933
} ) ;
1912
-
1934
+ Scheduler . unstable_clearLog ( ) ;
1913
1935
await act ( async ( ) => {
1914
1936
root . render ( < ErrorBoundary /> ) ;
1915
1937
} ) ;
@@ -1926,6 +1948,12 @@ describe('ReactErrorBoundaries', () => {
1926
1948
await act ( async ( ) => {
1927
1949
root . render ( < ErrorBoundary /> ) ;
1928
1950
} ) ;
1951
+ assertLog ( [
1952
+ 'ErrorBoundary constructor' ,
1953
+ 'ErrorBoundary componentWillMount' ,
1954
+ 'ErrorBoundary render success' ,
1955
+ 'ErrorBoundary componentDidMount' ,
1956
+ ] ) ;
1929
1957
await act ( async ( ) => {
1930
1958
root . render (
1931
1959
< ErrorBoundary >
@@ -1983,6 +2011,7 @@ describe('ReactErrorBoundaries', () => {
1983
2011
expect ( container . textContent ) . not . toContain ( 'Caught an error' ) ;
1984
2012
1985
2013
fail = true ;
2014
+ Scheduler . unstable_clearLog ( ) ;
1986
2015
await act ( async ( ) => {
1987
2016
root . render (
1988
2017
< ErrorBoundary >
0 commit comments