diff --git a/packages/amis-core/__tests__/jest.setup.js b/packages/amis-core/__tests__/jest.setup.js index 12865fa37..76c752071 100644 --- a/packages/amis-core/__tests__/jest.setup.js +++ b/packages/amis-core/__tests__/jest.setup.js @@ -1,4 +1,9 @@ const originalWarn = console.warn.bind(console.warn); +const originalGroupCollapsed = console.warn.bind(console.groupCollapsed); +const originalGroup = console.warn.bind(console.group); +const originalGroupEnd = console.warn.bind(console.groupEnd); +const originalDebug = console.warn.bind(console.debug); +const originalError = console.error.bind(console.error); require('@testing-library/jest-dom'); require('moment-timezone'); const moment = require('moment'); @@ -15,29 +20,30 @@ Object.defineProperty(window, 'DragEvent', { global.__buildVersion = ''; global.beforeAll(() => { - console.warn = msg => { - // warning 先关了,实在太吵。 - // const str = msg.toString(); - // if ( - // str.includes('componentWillMount') || - // str.includes('componentWillReceiveProps') - // ) { - // return; - // } - // originalWarn(msg); - }; - - /** - * Jest环境下关闭Log, 避免影响输出 - * 若要调试, 请使用@testing-library/react中的screen.debug方法 - * screen.debug是console.log(prettyDOM())的shortcut, 所以console.log不能禁用 - */ - console.error = jest.fn(); - console.debug = jest.fn(); - console.group = jest.fn(); - console.groupEnd = jest.fn(); + console.warn = + console.groupCollapsed = + console.group = + console.groupEnd = + console.debug = + console.error = + msg => { + // warning 先关了,实在太吵。 + // const str = msg.toString(); + // if ( + // str.includes('componentWillMount') || + // str.includes('componentWillReceiveProps') + // ) { + // return; + // } + // originalWarn(msg); + }; }); global.afterAll(() => { console.warn = originalWarn; + console.groupCollapsed = originalGroupCollapsed; + console.group = originalGroup; + console.groupEnd = originalGroupEnd; + console.debug = originalDebug; + console.error = originalError; cleanup(); }); diff --git a/packages/amis-ui/src/components/404.tsx b/packages/amis-ui/src/components/404.tsx index ae9164b82..fdb1d68c9 100644 --- a/packages/amis-ui/src/components/404.tsx +++ b/packages/amis-ui/src/components/404.tsx @@ -13,6 +13,7 @@ interface NotFoundProps { footerText?: React.ReactNode; classPrefix: string; classnames: ClassNamesFn; + children?: React.ReactElement; } export class NotFound extends React.Component { diff --git a/packages/amis/__tests__/jest.setup.js b/packages/amis/__tests__/jest.setup.js index 9638cce2b..1a1c12751 100644 --- a/packages/amis/__tests__/jest.setup.js +++ b/packages/amis/__tests__/jest.setup.js @@ -1,22 +1,32 @@ const originalWarn = console.warn.bind(console.warn); +const originalGroupCollapsed = console.warn.bind(console.groupCollapsed); +const originalGroupEnd = console.warn.bind(console.groupEnd); +const originalDebug = console.warn.bind(console.debug); require('@testing-library/jest-dom'); require('moment-timezone'); const moment = require('moment'); moment.tz.setDefault('Asia/Shanghai'); global.beforeAll(() => { - console.warn = msg => { - // warning 先关了,实在太吵。 - // const str = msg.toString(); - // if ( - // str.includes('componentWillMount') || - // str.includes('componentWillReceiveProps') - // ) { - // return; - // } - // originalWarn(msg); - }; + console.warn = + console.groupCollapsed = + console.groupEnd = + console.debug = + msg => { + // warning 先关了,实在太吵。 + // const str = msg.toString(); + // if ( + // str.includes('componentWillMount') || + // str.includes('componentWillReceiveProps') + // ) { + // return; + // } + // originalWarn(msg); + }; }); global.afterAll(() => { console.warn = originalWarn; + console.groupCollapsed = originalGroupCollapsed; + console.groupEnd = originalGroupEnd; + console.debug = originalDebug; });