mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
aecb3b6d11
* Use existing test warning filter for server tests We have a warning filter for our internal tests to ignore warnings that are too noisy or that we haven't removed from our test suite yet: shouldIgnoreConsoleError. Many of our server rendering tests don't use this filter, though, because it has its own special of asserting warnings. So I added the warning filter to the server tests, too. * Deprecate ReactDOM.render and ReactDOM.hydrate These are no longer supported in React 18. They are replaced by the `createRoot` API. The warning includes a link to documentation of the new API. Currently it redirects to the corresponding working group post. Here's the PR to set up the redirect: https://github.com/reactjs/reactjs.org/pull/3730 Many of our tests still use ReactDOM.render. We will need to gradually migrate them over to createRoot. In the meantime, I added the warnings to our internal warning filter.
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = function shouldIgnoreConsoleError(format, args) {
|
|
if (__DEV__) {
|
|
if (typeof format === 'string') {
|
|
if (format.indexOf('Error: Uncaught [') === 0) {
|
|
// This looks like an uncaught error from invokeGuardedCallback() wrapper
|
|
// in development that is reported by jsdom. Ignore because it's noisy.
|
|
return true;
|
|
}
|
|
if (format.indexOf('The above error occurred') === 0) {
|
|
// This looks like an error addendum from ReactFiberErrorLogger.
|
|
// Ignore it too.
|
|
return true;
|
|
}
|
|
if (
|
|
format.indexOf('ReactDOM.render is no longer supported in React 18') !==
|
|
-1 ||
|
|
format.indexOf(
|
|
'ReactDOM.hydrate is no longer supported in React 18'
|
|
) !== -1
|
|
) {
|
|
// We haven't finished migrating our tests to use createRoot.
|
|
return true;
|
|
}
|
|
}
|
|
} else {
|
|
if (
|
|
format != null &&
|
|
typeof format.message === 'string' &&
|
|
typeof format.stack === 'string' &&
|
|
args.length === 0
|
|
) {
|
|
// In production, ReactFiberErrorLogger logs error objects directly.
|
|
// They are noisy too so we'll try to ignore them.
|
|
return true;
|
|
}
|
|
if (
|
|
format.indexOf(
|
|
'act(...) is not supported in production builds of React'
|
|
) === 0
|
|
) {
|
|
// We don't yet support act() for prod builds, and warn for it.
|
|
// But we'd like to use act() ourselves for prod builds.
|
|
// Let's ignore the warning and #yolo.
|
|
return true;
|
|
}
|
|
}
|
|
// Looks legit
|
|
return false;
|
|
};
|