Updated readme. Cleaned up unused file.
This commit is contained in:
parent
4cbcf4a667
commit
7684c90fba
2 changed files with 17 additions and 28 deletions
|
@ -1,21 +0,0 @@
|
|||
import { act as reactAct } from 'react-dom/test-utils';
|
||||
|
||||
const SUPPRESSED_PREFIXES = [
|
||||
"Warning: Do not await the result of calling ReactTestUtils.act(...)",
|
||||
"Warning: An update to %s inside a test was not wrapped in act(...)",
|
||||
];
|
||||
|
||||
function isSuppressedErrorMessage(message: string): boolean {
|
||||
return SUPPRESSED_PREFIXES.some(sp => message.startsWith(sp));
|
||||
}
|
||||
|
||||
export async function act(f: () => void): Promise<void> {
|
||||
const oldError = window.console.error;
|
||||
window.console.error = (...args: any[]) => {
|
||||
if (!isSuppressedErrorMessage(args[0])) {
|
||||
oldError(...args);
|
||||
}
|
||||
};
|
||||
await Promise.race([reactAct(f), new Promise(res => setTimeout(res))]);
|
||||
window.console.error = oldError;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue