Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,9 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
}
}

function onRecoverableError(error) {
// TODO: Turn this on once tests are fixed
// console.error(error);
function onRecoverableError(error: mixed): void {
// eslint-disable-next-line react-internal/warning-args, react-internal/no-production-logging -- renderer is only used for testing.
console.error(error);
}
function onDefaultTransitionIndicator(): void | (() => void) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ describe('ReactIncrementalErrorHandling', () => {
'commit',
'commit',
]);
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
expect(ReactNoop).toMatchRenderedOutput(
<span prop="Everything is fine." />,
);
Expand Down Expand Up @@ -339,6 +343,10 @@ describe('ReactIncrementalErrorHandling', () => {
'commit',
'commit',
]);
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
// This should not include the offscreen content
expect(ReactNoop).toMatchRenderedOutput(
<>
Expand Down Expand Up @@ -1786,6 +1794,10 @@ describe('ReactIncrementalErrorHandling', () => {
});

// Should finish without throwing.
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
expect(root).toMatchRenderedOutput('Everything is fine.');
});

Expand Down Expand Up @@ -1832,6 +1844,10 @@ describe('ReactIncrementalErrorHandling', () => {
});
// Should render the final state without throwing the error.
assertLog(['Everything is fine.']);
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
expect(root).toMatchRenderedOutput('Everything is fine.');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

let React;
let ReactNoop;
let assertConsoleErrorDev;
let waitForAll;
let waitForThrow;

Expand All @@ -22,6 +23,7 @@ describe('ReactIncrementalErrorReplay', () => {
ReactNoop = require('react-noop-renderer');

const InternalTestUtils = require('internal-test-utils');
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
waitForAll = InternalTestUtils.waitForAll;
waitForThrow = InternalTestUtils.waitForThrow;
});
Expand Down Expand Up @@ -50,5 +52,9 @@ describe('ReactIncrementalErrorReplay', () => {
}
ReactNoop.render(<App />);
await waitForAll([]);
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
});
});
13 changes: 9 additions & 4 deletions packages/react-reconciler/src/__tests__/useMemoCache-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let React;
let ReactNoop;
let Scheduler;
let act;
let assertConsoleErrorDev;
let assertLog;
let useMemo;
let useState;
Expand All @@ -26,8 +27,10 @@ describe('useMemoCache()', () => {
React = require('react');
ReactNoop = require('react-noop-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;
assertLog = require('internal-test-utils').assertLog;
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils.act;
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
assertLog = InternalTestUtils.assertLog;
useMemo = React.useMemo;
useMemoCache = require('react/compiler-runtime').c;
useState = React.useState;
Expand Down Expand Up @@ -256,8 +259,6 @@ describe('useMemoCache()', () => {
return `${data.text} (n=${props.n})`;
});

spyOnDev(console, 'error');

const root = ReactNoop.createRoot();
await act(() => {
root.render(
Expand All @@ -274,6 +275,10 @@ describe('useMemoCache()', () => {
// this triggers a throw.
setN(1);
});
assertConsoleErrorDev([
'Error: There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root.' +
'\n in <stack>',
]);
expect(root).toMatchRenderedOutput('Count 0 (n=1)');
expect(Text).toBeCalledTimes(2);
expect(data).toBe(data0);
Expand Down
Loading