@samitouri / QOS-React-2 / commits / 49b0f87d10

Suppress act/renderer warning for DevTools tests

Brian Vaughn committed Aug 27, 2019 at 10:46 UTC 49b0f87d10a2fab056c29f24228acf3ce2bcc26b
1 file changed +9 -1
packages/react-devtools-shared/src/__tests__/setupTests.js
+9 -1
@@ -27,9 +27,17 @@ env.beforeEach(() => {
27 const originalConsoleError = console.error;
28 // $FlowFixMe
29 console.error = (...args) => {
30 - if (args[0] === 'Warning: React DevTools encountered an error: %s') {
30 + const firstArg = args[0];
31 + if (firstArg === 'Warning: React DevTools encountered an error: %s') {
32 // Rethrow errors from React.
33 throw args[1];
34 + } else if (
35 + typeof firstArg === 'string' &&
36 + firstArg.startsWith("Warning: It looks like you're using the wrong act()")
37 + ) {
38 + // DevTools intentionally wraps updates with acts from both DOM and test-renderer,
39 + // since test updates are expected to impact both renderers.
40 + return;
41 }
42 originalConsoleError.apply(console, args);
43 };