chore: 尝试修复一些 ts 报错

This commit is contained in:
2betop 2023-03-23 16:05:28 +08:00
parent 0291fdc7d3
commit db7e33a8c2
3 changed files with 49 additions and 32 deletions

View File

@ -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();
});

View File

@ -13,6 +13,7 @@ interface NotFoundProps {
footerText?: React.ReactNode;
classPrefix: string;
classnames: ClassNamesFn;
children?: React.ReactElement;
}
export class NotFound extends React.Component<NotFoundProps, any> {

View File

@ -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;
});