Skip to content

Commit a1fc3c6

Browse files
Improve act() warning suppression logic for floating-ui
1 parent 92e71ca commit a1fc3c6

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/test/index.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ expect.extend(toHaveNoViolations);
77
const originalError = console.error;
88
beforeAll(() => {
99
console.error = (...args) => {
10-
// Check if any of the arguments contains the floating-ui act warning
11-
const hasFloatingActWarning = args.some(
12-
(arg) =>
13-
typeof arg === "string" &&
14-
arg.includes(
15-
"An update to withFloating(PopperComponent) inside a test was not wrapped in act",
16-
),
17-
);
10+
// Check the first argument (the error message)
11+
const firstArg = args[0];
12+
const firstArgStr =
13+
typeof firstArg === "string"
14+
? firstArg
15+
: firstArg instanceof Error
16+
? firstArg.message
17+
: String(firstArg);
1818

19-
if (hasFloatingActWarning) {
19+
// Suppress floating-ui act warnings
20+
if (
21+
firstArgStr.includes("An update to withFloating(PopperComponent)") &&
22+
firstArgStr.includes("inside a test was not wrapped in act")
23+
) {
2024
return;
2125
}
2226

0 commit comments

Comments
 (0)