mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-02 03:25:53 +01:00
fix: missing act()
in flowchart tests (#8354)
This commit is contained in:
parent
d5f4ee7b3f
commit
1ea5b26f25
@ -36,7 +36,7 @@ describe("flow chart creation", () => {
|
|||||||
height: 100,
|
height: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
h.elements = [rectangle];
|
API.setElements([rectangle]);
|
||||||
API.setSelectedElements([rectangle]);
|
API.setSelectedElements([rectangle]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ describe("flow chart navigation", () => {
|
|||||||
height: 100,
|
height: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
h.elements = [rectangle];
|
API.setElements([rectangle]);
|
||||||
API.setSelectedElements([rectangle]);
|
API.setSelectedElements([rectangle]);
|
||||||
|
|
||||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||||
@ -234,7 +234,7 @@ describe("flow chart navigation", () => {
|
|||||||
height: 100,
|
height: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
h.elements = [rectangle];
|
API.setElements([rectangle]);
|
||||||
API.setSelectedElements([rectangle]);
|
API.setSelectedElements([rectangle]);
|
||||||
|
|
||||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||||
@ -325,7 +325,7 @@ describe("flow chart navigation", () => {
|
|||||||
height: 100,
|
height: 100,
|
||||||
});
|
});
|
||||||
|
|
||||||
h.elements = [rectangle];
|
API.setElements([rectangle]);
|
||||||
API.setSelectedElements([rectangle]);
|
API.setSelectedElements([rectangle]);
|
||||||
|
|
||||||
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
Keyboard.withModifierKeys({ ctrl: true }, () => {
|
||||||
|
2
packages/excalidraw/tests/helpers/colorize.ts
Normal file
2
packages/excalidraw/tests/helpers/colorize.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const yellow = (str: string) => `\u001b[33m${str}\u001b[0m`;
|
||||||
|
export const red = (str: string) => `\u001b[31m${str}\u001b[0m`;
|
@ -5,6 +5,7 @@ import fs from "fs";
|
|||||||
import { vi } from "vitest";
|
import { vi } from "vitest";
|
||||||
import polyfill from "./packages/excalidraw/polyfill";
|
import polyfill from "./packages/excalidraw/polyfill";
|
||||||
import { testPolyfills } from "./packages/excalidraw/tests/helpers/polyfills";
|
import { testPolyfills } from "./packages/excalidraw/tests/helpers/polyfills";
|
||||||
|
import { yellow } from "./packages/excalidraw/tests/helpers/colorize";
|
||||||
|
|
||||||
Object.assign(globalThis, testPolyfills);
|
Object.assign(globalThis, testPolyfills);
|
||||||
|
|
||||||
@ -98,18 +99,20 @@ const element = document.createElement("div");
|
|||||||
element.id = "root";
|
element.id = "root";
|
||||||
document.body.appendChild(element);
|
document.body.appendChild(element);
|
||||||
|
|
||||||
const logger = console.error.bind(console);
|
const _consoleError = console.error.bind(console);
|
||||||
console.error = (...args) => {
|
console.error = (...args) => {
|
||||||
// the react's act() warning usually doesn't contain any useful stack trace
|
// 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,
|
// 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
|
// also stripping the actual component stack trace as it's not useful
|
||||||
if (args[0]?.includes("act(")) {
|
if (args[0]?.includes("act(")) {
|
||||||
logger(
|
_consoleError(
|
||||||
`<<< WARNING: test "${
|
yellow(
|
||||||
expect.getState().currentTestName
|
`<<< WARNING: test "${
|
||||||
}" does not wrap some state update in act() >>>`,
|
expect.getState().currentTestName
|
||||||
|
}" does not wrap some state update in act() >>>`,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
logger(...args);
|
_consoleError(...args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user