Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ describe('ReactErrorBoundaries', () => {
});
}).rejects.toThrow('Hello');

Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await expect(async () => {
Expand All @@ -592,6 +593,7 @@ describe('ReactErrorBoundaries', () => {
});
}).rejects.toThrow('Hello');

Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await expect(async () => {
Expand All @@ -607,28 +609,32 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render(<BrokenComponentWillUpdate />);
});
Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render(<BrokenComponentWillUpdate />);
});
}).rejects.toThrow('Hello');

Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await act(async () => {
root.render(<BrokenComponentWillReceiveProps />);
});
Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render(<BrokenComponentWillReceiveProps />);
});
}).rejects.toThrow('Hello');

Scheduler.unstable_clearLog();
container = document.createElement('div');
root = ReactDOMClient.createRoot(container);
await act(async () => {
root.render(<BrokenComponentDidUpdate />);
});
Scheduler.unstable_clearLog();
await expect(async () => {
await act(async () => {
root.render(<BrokenComponentDidUpdate />);
Expand All @@ -642,6 +648,7 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render(<BrokenComponentWillUnmount />);
});
Scheduler.unstable_clearLog();
await expect(async () => {
await act(() => root.unmount());
}).rejects.toThrow('Hello');
Expand All @@ -663,6 +670,15 @@ describe('ReactErrorBoundaries', () => {
root2.render(<BrokenRender />);
});
}).rejects.toThrow('Hello');

assertLog([
'BrokenRender constructor',
'BrokenRender componentWillMount',
'BrokenRender render [!]',
'BrokenRender constructor',
'BrokenRender componentWillMount',
'BrokenRender render [!]',
]);
await act(async () => {
root3.render(
<ErrorBoundary>
Expand All @@ -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(<span>After 1</span>);
});
Scheduler.unstable_clearLog();
await act(async () => {
root2.render(<span>After 2</span>);
});
Scheduler.unstable_clearLog();
await act(async () => {
root3.render(<ErrorBoundary forceRetry={true}>After 3</ErrorBoundary>);
});
Expand Down Expand Up @@ -1828,6 +1847,7 @@ describe('ReactErrorBoundaries', () => {
);
});

Scheduler.unstable_clearLog();
await act(async () => {
root.render(
<ErrorBoundary>
Expand Down Expand Up @@ -1879,6 +1899,7 @@ describe('ReactErrorBoundaries', () => {
);
});
expect(container.textContent).toBe('Caught an error: Hello.');
Scheduler.unstable_clearLog();

await act(async () => {
root.render(
Expand All @@ -1888,6 +1909,7 @@ describe('ReactErrorBoundaries', () => {
);
});
expect(container.textContent).toBe('Caught an error: Hello.');
Scheduler.unstable_clearLog();

await act(async () => {
root.render(<div>Other screen</div>);
Expand All @@ -1909,7 +1931,7 @@ describe('ReactErrorBoundaries', () => {
</ErrorBoundary>,
);
});

Scheduler.unstable_clearLog();
await act(async () => {
root.render(<ErrorBoundary />);
});
Expand All @@ -1926,6 +1948,12 @@ describe('ReactErrorBoundaries', () => {
await act(async () => {
root.render(<ErrorBoundary />);
});
assertLog([
'ErrorBoundary constructor',
'ErrorBoundary componentWillMount',
'ErrorBoundary render success',
'ErrorBoundary componentDidMount',
]);
await act(async () => {
root.render(
<ErrorBoundary>
Expand Down Expand Up @@ -1983,6 +2011,7 @@ describe('ReactErrorBoundaries', () => {
expect(container.textContent).not.toContain('Caught an error');

fail = true;
Scheduler.unstable_clearLog();
await act(async () => {
root.render(
<ErrorBoundary>
Expand Down