Browse Source

chore: test clean up log (#40955)

pull/40940/head
二货爱吃白萝卜 2 years ago
committed by GitHub
parent
commit
b4015b6370
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      tests/setup.js

17
tests/setup.js

@ -4,6 +4,21 @@ const util = require('util');
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log('Current React Version:', React.version); 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 */ /* eslint-disable global-require */
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
global.window.resizeTo = (width, height) => { global.window.resizeTo = (width, height) => {
@ -17,7 +32,7 @@ if (typeof window !== 'undefined') {
Object.defineProperty(global.window, 'matchMedia', { Object.defineProperty(global.window, 'matchMedia', {
writable: true, writable: true,
configurable: true, configurable: true,
value: jest.fn(query => ({ value: jest.fn((query) => ({
matches: query.includes('max-width'), matches: query.includes('max-width'),
addListener: jest.fn(), addListener: jest.fn(),
removeListener: jest.fn(), removeListener: jest.fn(),

Loading…
Cancel
Save