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

This commit is contained in:
Aaron Perez 2026-06-24 16:20:23 -05:00 committed by GitHub
parent 64ac33305c
commit a75b83a319
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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));
});