mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 00:08:27 +08:00
5d3b45551d
* test: init of test * test: update snapshot * test: update snapshot * chore: adjust size limit * test: update snapshot * test: update snapshot * test: update snapshot * chore: update snapshot --------- Co-authored-by: lijianan <574980606@qq.com>
37 lines
838 B
TypeScript
37 lines
838 B
TypeScript
// eslint-disable-next-line no-console
|
|
const originError = console.error;
|
|
|
|
export function isSafeWarning(message: boolean, all = false) {
|
|
const list = ['useLayoutEffect does nothing on the server'];
|
|
|
|
if (all) {
|
|
list.push('is deprecated in StrictMode');
|
|
}
|
|
|
|
return list.some((msg) => String(message).includes(msg));
|
|
}
|
|
|
|
/** 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 (isSafeWarning(msg)) {
|
|
return;
|
|
}
|
|
originError(msg, ...rest);
|
|
});
|
|
|
|
return errorSpy;
|
|
}
|
|
|
|
export default function excludeAllWarning() {
|
|
let cleanUp: Function;
|
|
|
|
beforeAll(() => {
|
|
cleanUp = excludeWarning().mockRestore;
|
|
});
|
|
|
|
afterAll(() => {
|
|
cleanUp();
|
|
});
|
|
}
|