mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
28 lines
612 B
TypeScript
28 lines
612 B
TypeScript
|
const originError = console.error;
|
||
|
|
||
|
/** This function will remove `useLayoutEffect` server side warning. Since it's useless. */
|
||
|
export function excludeWarning() {
|
||
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation((msg, ...rest) => {
|
||
|
if (String(msg).includes('useLayoutEffect does nothing on the server')) {
|
||
|
return;
|
||
|
}
|
||
|
originError(msg, ...rest);
|
||
|
});
|
||
|
|
||
|
return () => {
|
||
|
errorSpy.mockRestore();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export default function excludeAllWarning() {
|
||
|
let cleanUp: Function;
|
||
|
|
||
|
beforeAll(() => {
|
||
|
cleanUp = excludeWarning();
|
||
|
});
|
||
|
|
||
|
afterAll(() => {
|
||
|
cleanUp();
|
||
|
});
|
||
|
}
|