Skip to content

Automate browser based workflows with AI

fix(SKY-11404): flush Radix focus-scope unmount timer in vitest teardown (#6795)

Aaron Pereza75b83a31951
diff --git a/skyvern-frontend/vitest.setup.ts b/skyvern-frontend/vitest.setup.ts
index 4d98cfd7e..15289b23c 100644
--- a/skyvern-frontend/vitest.setup.ts
+++ b/skyvern-frontend/vitest.setup.ts
@@ -1,3 +1,6 @@
+import { cleanup } from "@testing-library/react";
+import { afterEach } from "vitest";
+
type StorageRecord = Record<string, string>;
const createMemoryStorage = (): Storage => {
@@ -58,3 +61,11 @@ if (typeof window !== "undefined") {
value: window.CustomEvent,
});
}
+
+// Radix FocusScope schedules a setTimeout(..., 0) on unmount that dispatches a
+// CustomEvent. Flush it within the test's realm (cleanup then one macrotask) so
+// it can't fire during teardown against a swapped realm and red the run.
+afterEach(async () => {
+ cleanup();
+ await new Promise((resolve) => setTimeout(resolve, 0));
+});