1- import { afterEach , beforeEach , expect , test } from "bun:test" ;
1+ import { afterEach , beforeEach , expect , test as bunTest } from "bun:test" ;
22import { Window } from "happy-dom" ;
33import { act , useEffect , useState } from "react" ;
44import type { Root } from "react-dom/client" ;
@@ -9,6 +9,13 @@ import {
99 useKeyedClientResource ,
1010} from "../src/client-resource" ;
1111
12+ // Bun's default per-test budget is 5s. waitFor below is 15s (busy CI runners),
13+ // so every case in this file needs a higher ceiling or the suite fails as
14+ // "waitFor timed out" while the predicate never got its full window.
15+ function test ( name : string , fn : ( ) => void | Promise < void > ) : void {
16+ bunTest ( name , fn , { timeout : 30_000 } ) ;
17+ }
18+
1219const globals = [ "document" , "window" , "navigator" , "IS_REACT_ACT_ENVIRONMENT" ] as const ;
1320let previousGlobals : Record < ( typeof globals ) [ number ] , unknown > ;
1421let testWindow : Window ;
@@ -37,11 +44,13 @@ afterEach(() => {
3744 * 1s was enough on an idle machine and not enough on a loaded CI runner: the
3845 * visibility test waits for a poll that only fires after a real 20ms interval
3946 * plus a React commit, and macOS CI blew through the budget mid-suite while the
40- * same file passed in isolation. The assertions below are about *whether* the
41- * fetch happens, never about how fast, so a longer ceiling costs nothing on a
42- * healthy run — it only stops a busy runner from reading as a product bug.
47+ * same file passed in isolation. Windows GHA later timed out the same waits at
48+ * 5s under suite load (`waitFor timed out` on #827). The assertions below are
49+ * about *whether* the fetch happens, never about how fast, so a longer ceiling
50+ * costs nothing on a healthy run — it only stops a busy runner from reading as
51+ * a product bug.
4352 */
44- async function waitFor ( predicate : ( ) => boolean , timeoutMs = 5000 ) : Promise < void > {
53+ async function waitFor ( predicate : ( ) => boolean , timeoutMs = 15_000 ) : Promise < void > {
4554 const start = Date . now ( ) ;
4655 while ( ! predicate ( ) ) {
4756 if ( Date . now ( ) - start > timeoutMs ) throw new Error ( "waitFor timed out" ) ;
0 commit comments