Skip to content

Commit d0a3161

Browse files
committed
Update test harness lifecycle constraints comment
1 parent 089cfb9 commit d0a3161

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tests/test-utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ export interface TestHarness {
5050
* single active harness per test.
5151
*
5252
* CRITICAL: ESM static imports resolve before any module body runs. This means
53-
* spawn/renderer.ts registers the production frame scheduler at import time,
54-
* and createTestHarness() (called in beforeEach) always wins because tests
55-
* import this module after production modules. Never use dynamic import() to
56-
* load spawn/renderer.ts after createTestHarness() — the production scheduler
57-
* would overwrite the test one.
53+
* spawn/renderer.ts registers the production frame scheduler at import time.
54+
* The test harness replaces the frame scheduler with a fresh test scheduler.
55+
* This works correctly as long as test-utils.ts is imported before spawn/renderer.ts
56+
* in the module graph. Never use dynamic import() to load spawn/renderer.ts after
57+
* createTestHarness() — the production scheduler would overwrite the test one.
5858
*/
5959
export function createTestHarness(): TestHarness {
6060
const previousSingletons = getSingletons();
61+
6162
const singletons: RuntimeSingletons = {
6263
writeLock: createWriteLock(),
6364
writeContext: new AsyncLocalStorage<true>(),
@@ -90,4 +91,4 @@ export function createTestHarness(): TestHarness {
9091
console.error = originalError;
9192
},
9293
};
93-
}
94+
}

0 commit comments

Comments
 (0)