mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: missing act()
in flowchart tests (#8354)
This commit is contained in:
parent
d5f4ee7b3f
commit
1ea5b26f25
3 changed files with 15 additions and 10 deletions
|
@ -5,6 +5,7 @@ import fs from "fs";
|
|||
import { vi } from "vitest";
|
||||
import polyfill from "./packages/excalidraw/polyfill";
|
||||
import { testPolyfills } from "./packages/excalidraw/tests/helpers/polyfills";
|
||||
import { yellow } from "./packages/excalidraw/tests/helpers/colorize";
|
||||
|
||||
Object.assign(globalThis, testPolyfills);
|
||||
|
||||
|
@ -98,18 +99,20 @@ const element = document.createElement("div");
|
|||
element.id = "root";
|
||||
document.body.appendChild(element);
|
||||
|
||||
const logger = console.error.bind(console);
|
||||
const _consoleError = console.error.bind(console);
|
||||
console.error = (...args) => {
|
||||
// the react's act() warning usually doesn't contain any useful stack trace
|
||||
// so we're catching the log and re-logging the message with the test name,
|
||||
// also stripping the actual component stack trace as it's not useful
|
||||
if (args[0]?.includes("act(")) {
|
||||
logger(
|
||||
`<<< WARNING: test "${
|
||||
expect.getState().currentTestName
|
||||
}" does not wrap some state update in act() >>>`,
|
||||
_consoleError(
|
||||
yellow(
|
||||
`<<< WARNING: test "${
|
||||
expect.getState().currentTestName
|
||||
}" does not wrap some state update in act() >>>`,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
logger(...args);
|
||||
_consoleError(...args);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue