diff --git a/packages/core/src/store/draft-attachment-snapshot.test.ts b/packages/core/src/store/draft-attachment-snapshot.test.ts index 7a808dbc95..7476cce6ed 100644 --- a/packages/core/src/store/draft-attachment-snapshot.test.ts +++ b/packages/core/src/store/draft-attachment-snapshot.test.ts @@ -39,6 +39,15 @@ test('draft snapshots do not enumerate unaffected procedural attachment maps', ( ] }), ]) as Record + // `updateNode` batches its dirty-node flush through rAF, which bun's test + // runtime has no DOM to supply. Every other core test that reaches this path + // stubs it; this one used to pass only when one of them happened to run first + // and leak the global, so on a runner that ordered the files differently it + // failed with a bare ReferenceError. + const savedRaf = globalThis.requestAnimationFrame + const savedCancelRaf = globalThis.cancelAnimationFrame + globalThis.requestAnimationFrame = (() => 0) as typeof requestAnimationFrame + globalThis.cancelAnimationFrame = (() => {}) as typeof cancelAnimationFrame const stop = subscribeSceneCommits((commit) => { expect(commit.current.nodes[draft.id]).toBeUndefined() expect((commit.current.nodes['procedural-item_0'] as ProceduralItemNode).attachments).toBe( @@ -68,5 +77,7 @@ test('draft snapshots do not enumerate unaffected procedural attachment maps', ( useScene.setState(saved) useScene.temporal.getState().clear() useScene.temporal.getState().resume() + globalThis.requestAnimationFrame = savedRaf + globalThis.cancelAnimationFrame = savedCancelRaf } })