Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Ignore ReactDOM.render deprecation warning #26683

Merged
merged 4 commits into from
Jun 11, 2021
Merged
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
5 changes: 2 additions & 3 deletions test/utils/createServerRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ export default function createServerRender(options = {}) {
const { expectUseLayoutEffectWarning = false } = options;

beforeEach(() => {
const originalConsoleError = console.error;
stub(console, 'error').callsFake((message, ...args) => {
const isUseLayoutEffectWarning = /Warning: useLayoutEffect does nothing on the server/.test(
message,
);

if (!expectUseLayoutEffectWarning || !isUseLayoutEffectWarning) {
// callThrough
// eslint-disable-next-line no-console
console.info(message, ...args);
throw new Error(message, ...args);
originalConsoleError(message, ...args);
}
});
});
Expand Down
5 changes: 5 additions & 0 deletions test/utils/initMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ chai.use((chaiAPI, utils) => {
const originalMethod = console[methodName];

const consoleMatcher = (format: string, ...args: readonly unknown[]) => {
// Ignore ReactDOM.render deprecation warning
// TODO: Remove once we no longer use legacy roots.
if (format.indexOf('Use createRoot instead.') !== -1) {
return;
}
const actualMessage = formatUtil(format, ...args);
const expectedMessage = remainingMessages.shift();

Expand Down
6 changes: 6 additions & 0 deletions test/utils/mochaHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ function createUnexpectedConsoleMessagesHooks(Mocha, methodName, expectedMatcher
}
}

// Ignore ReactDOM.render deprecation warning
// TODO: Remove once we no longer use legacy roots.
if (message.indexOf('Use createRoot instead.') !== -1) {
return;
}

unexpectedCalls.push([
// first line includes the (empty) error message
// i.e. Remove the `Error:` line
Expand Down