diff --git a/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js b/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
index ffa923de3de58..684f011cb6009 100644
--- a/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactErrorBoundaries-test.internal.js
@@ -584,6 +584,7 @@ describe('ReactErrorBoundaries', () => {
});
}).rejects.toThrow('Hello');
+ Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await expect(async () => {
@@ -592,6 +593,7 @@ describe('ReactErrorBoundaries', () => {
});
}).rejects.toThrow('Hello');
+ Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await expect(async () => {
@@ -607,28 +609,32 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render();
});
+ Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render();
});
}).rejects.toThrow('Hello');
+ Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await act(async () => {
root.render();
});
+ Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render();
});
}).rejects.toThrow('Hello');
-
+ Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await act(async () => {
root.render();
});
+ Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render();
@@ -642,6 +648,7 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render();
});
+ Scheduler.unstable_clearLog();
await expect(async () => {
await act(() => root.unmount());
}).rejects.toThrow('Hello');
@@ -663,6 +670,15 @@ describe('ReactErrorBoundaries', () => {
root2.render();
});
}).rejects.toThrow('Hello');
+
+ assertLog([
+ 'BrokenRender constructor',
+ 'BrokenRender componentWillMount',
+ 'BrokenRender render [!]',
+ 'BrokenRender constructor',
+ 'BrokenRender componentWillMount',
+ 'BrokenRender render [!]',
+ ]);
await act(async () => {
root3.render(
@@ -674,12 +690,15 @@ describe('ReactErrorBoundaries', () => {
expect(container2.firstChild).toBe(null);
expect(container3.firstChild.textContent).toBe('Caught an error: Hello.');
+ Scheduler.unstable_clearLog();
await act(async () => {
root1.render(After 1);
});
+ Scheduler.unstable_clearLog();
await act(async () => {
root2.render(After 2);
});
+ Scheduler.unstable_clearLog();
await act(async () => {
root3.render(After 3);
});
@@ -1828,6 +1847,7 @@ describe('ReactErrorBoundaries', () => {
);
});
+ Scheduler.unstable_clearLog();
await act(async () => {
root.render(
@@ -1879,6 +1899,7 @@ describe('ReactErrorBoundaries', () => {
);
});
expect(container.textContent).toBe('Caught an error: Hello.');
+ Scheduler.unstable_clearLog();
await act(async () => {
root.render(
@@ -1888,6 +1909,7 @@ describe('ReactErrorBoundaries', () => {
);
});
expect(container.textContent).toBe('Caught an error: Hello.');
+ Scheduler.unstable_clearLog();
await act(async () => {
root.render(Other screen
);
@@ -1909,7 +1931,7 @@ describe('ReactErrorBoundaries', () => {
,
);
});
-
+ Scheduler.unstable_clearLog();
await act(async () => {
root.render();
});
@@ -1926,6 +1948,12 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render();
});
+ assertLog([
+ 'ErrorBoundary constructor',
+ 'ErrorBoundary componentWillMount',
+ 'ErrorBoundary render success',
+ 'ErrorBoundary componentDidMount',
+ ]);
await act(async () => {
root.render(
@@ -1983,6 +2011,7 @@ describe('ReactErrorBoundaries', () => {
expect(container.textContent).not.toContain('Caught an error');
fail = true;
+ Scheduler.unstable_clearLog();
await act(async () => {
root.render(