Skip to content

Commit 33b5002

Browse files
committed
Fix flaky CI frontend job: unmount React trees after each test
React 19's scheduler could flush deferred work after vitest tore down the jsdom environment (window is not defined), failing the run on slow runners. Register a global @testing-library/react cleanup in the vitest setup.
1 parent 9096aea commit 33b5002

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

frontend/src/test-setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ Object.defineProperty(window, "matchMedia", {
2222
dispatchEvent: () => false,
2323
}),
2424
});
25+
26+
// Unmount rendered trees after every test so React's scheduler has no
27+
// deferred work left when vitest tears down the jsdom environment.
28+
import { cleanup } from "@testing-library/react";
29+
import { afterEach } from "vitest";
30+
31+
afterEach(() => {
32+
cleanup();
33+
});

0 commit comments

Comments
 (0)