@@ -584,6 +584,7 @@ describe('ReactErrorBoundaries', () => {
584584 } ) ;
585585 } ) . rejects . toThrow ( 'Hello' ) ;
586586
587+ Scheduler . unstable_clearLog ( ) ;
587588 container = document . createElement ( 'div' ) ;
588589 root = ReactDOMClient . createRoot ( container ) ;
589590 await expect ( async ( ) => {
@@ -592,6 +593,7 @@ describe('ReactErrorBoundaries', () => {
592593 } ) ;
593594 } ) . rejects . toThrow ( 'Hello' ) ;
594595
596+ Scheduler . unstable_clearLog ( ) ;
595597 container = document . createElement ( 'div' ) ;
596598 root = ReactDOMClient . createRoot ( container ) ;
597599 await expect ( async ( ) => {
@@ -607,28 +609,32 @@ describe('ReactErrorBoundaries', () => {
607609 await act ( async ( ) => {
608610 root . render ( < BrokenComponentWillUpdate /> ) ;
609611 } ) ;
612+ Scheduler . unstable_clearLog ( ) ;
610613 await expect ( async ( ) => {
611614 await act ( async ( ) => {
612615 root . render ( < BrokenComponentWillUpdate /> ) ;
613616 } ) ;
614617 } ) . rejects . toThrow ( 'Hello' ) ;
615618
619+ Scheduler . unstable_clearLog ( ) ;
616620 container = document . createElement ( 'div' ) ;
617621 root = ReactDOMClient . createRoot ( container ) ;
618622 await act ( async ( ) => {
619623 root . render ( < BrokenComponentWillReceiveProps /> ) ;
620624 } ) ;
625+ Scheduler . unstable_clearLog ( ) ;
621626 await expect ( async ( ) => {
622627 await act ( async ( ) => {
623628 root . render ( < BrokenComponentWillReceiveProps /> ) ;
624629 } ) ;
625630 } ) . rejects . toThrow ( 'Hello' ) ;
626-
631+ Scheduler . unstable_clearLog ( ) ;
627632 container = document . createElement ( 'div' ) ;
628633 root = ReactDOMClient . createRoot ( container ) ;
629634 await act ( async ( ) => {
630635 root . render ( < BrokenComponentDidUpdate /> ) ;
631636 } ) ;
637+ Scheduler . unstable_clearLog ( ) ;
632638 await expect ( async ( ) => {
633639 await act ( async ( ) => {
634640 root . render ( < BrokenComponentDidUpdate /> ) ;
@@ -642,6 +648,7 @@ describe('ReactErrorBoundaries', () => {
642648 await act ( async ( ) => {
643649 root . render ( < BrokenComponentWillUnmount /> ) ;
644650 } ) ;
651+ Scheduler . unstable_clearLog ( ) ;
645652 await expect ( async ( ) => {
646653 await act ( ( ) => root . unmount ( ) ) ;
647654 } ) . rejects . toThrow ( 'Hello' ) ;
@@ -663,6 +670,15 @@ describe('ReactErrorBoundaries', () => {
663670 root2 . render ( < BrokenRender /> ) ;
664671 } ) ;
665672 } ) . 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+ ] ) ;
666682 await act ( async ( ) => {
667683 root3 . render (
668684 < ErrorBoundary >
@@ -674,12 +690,15 @@ describe('ReactErrorBoundaries', () => {
674690 expect ( container2 . firstChild ) . toBe ( null ) ;
675691 expect ( container3 . firstChild . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
676692
693+ Scheduler . unstable_clearLog ( ) ;
677694 await act ( async ( ) => {
678695 root1 . render ( < span > After 1</ span > ) ;
679696 } ) ;
697+ Scheduler . unstable_clearLog ( ) ;
680698 await act ( async ( ) => {
681699 root2 . render ( < span > After 2</ span > ) ;
682700 } ) ;
701+ Scheduler . unstable_clearLog ( ) ;
683702 await act ( async ( ) => {
684703 root3 . render ( < ErrorBoundary forceRetry = { true } > After 3</ ErrorBoundary > ) ;
685704 } ) ;
@@ -1828,6 +1847,7 @@ describe('ReactErrorBoundaries', () => {
18281847 ) ;
18291848 } ) ;
18301849
1850+ Scheduler . unstable_clearLog ( ) ;
18311851 await act ( async ( ) => {
18321852 root . render (
18331853 < ErrorBoundary >
@@ -1879,6 +1899,7 @@ describe('ReactErrorBoundaries', () => {
18791899 ) ;
18801900 } ) ;
18811901 expect ( container . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
1902+ Scheduler . unstable_clearLog ( ) ;
18821903
18831904 await act ( async ( ) => {
18841905 root . render (
@@ -1888,6 +1909,7 @@ describe('ReactErrorBoundaries', () => {
18881909 ) ;
18891910 } ) ;
18901911 expect ( container . textContent ) . toBe ( 'Caught an error: Hello.' ) ;
1912+ Scheduler . unstable_clearLog ( ) ;
18911913
18921914 await act ( async ( ) => {
18931915 root . render ( < div > Other screen</ div > ) ;
@@ -1909,7 +1931,7 @@ describe('ReactErrorBoundaries', () => {
19091931 </ ErrorBoundary > ,
19101932 ) ;
19111933 } ) ;
1912-
1934+ Scheduler . unstable_clearLog ( ) ;
19131935 await act ( async ( ) => {
19141936 root . render ( < ErrorBoundary /> ) ;
19151937 } ) ;
@@ -1926,6 +1948,12 @@ describe('ReactErrorBoundaries', () => {
19261948 await act ( async ( ) => {
19271949 root . render ( < ErrorBoundary /> ) ;
19281950 } ) ;
1951+ assertLog ( [
1952+ 'ErrorBoundary constructor' ,
1953+ 'ErrorBoundary componentWillMount' ,
1954+ 'ErrorBoundary render success' ,
1955+ 'ErrorBoundary componentDidMount' ,
1956+ ] ) ;
19291957 await act ( async ( ) => {
19301958 root . render (
19311959 < ErrorBoundary >
@@ -1983,6 +2011,7 @@ describe('ReactErrorBoundaries', () => {
19832011 expect ( container . textContent ) . not . toContain ( 'Caught an error' ) ;
19842012
19852013 fail = true ;
2014+ Scheduler . unstable_clearLog ( ) ;
19862015 await act ( async ( ) => {
19872016 root . render (
19882017 < ErrorBoundary >
0 commit comments