diff --git a/tests/setup.js b/tests/setup.js index afd91cdbfe..25f9bf9901 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -4,6 +4,21 @@ const util = require('util'); // eslint-disable-next-line no-console console.log('Current React Version:', React.version); +const originConsoleErr = console.error; + +// Hack off React warning to avoid too large log in CI. +console.error = (...args) => { + const str = args.join('').replace(/\n/g, ''); + + if ( + ['validateDOMNesting', 'on an unmounted component', 'not wrapped in act'].every( + (warn) => !str.includes(warn), + ) + ) { + originConsoleErr(...args); + } +}; + /* eslint-disable global-require */ if (typeof window !== 'undefined') { global.window.resizeTo = (width, height) => { @@ -17,7 +32,7 @@ if (typeof window !== 'undefined') { Object.defineProperty(global.window, 'matchMedia', { writable: true, configurable: true, - value: jest.fn(query => ({ + value: jest.fn((query) => ({ matches: query.includes('max-width'), addListener: jest.fn(), removeListener: jest.fn(),