// jsdom lacks a few SVG/DOM APIs JointJS pokes at during construction. import { vi } from 'vitest' if (!('performance' in globalThis)) { // @ts-expect-error minimal shim globalThis.performance = { now: () => 0 } } if (!globalThis.requestAnimationFrame) { globalThis.requestAnimationFrame = ((cb: FrameRequestCallback) => setTimeout(() => cb(0), 16) as unknown as number) as typeof requestAnimationFrame globalThis.cancelAnimationFrame = ((id: number) => clearTimeout(id)) as typeof cancelAnimationFrame } // jsdom's SVGElement.getBBox / getScreenCTM are stubs; provide safe values. if (typeof SVGElement !== 'undefined') { // @ts-expect-error patching prototype for tests SVGElement.prototype.getBBox ||= () => ({ x: 0, y: 0, width: 60, height: 60 }) // @ts-expect-error patching prototype for tests SVGElement.prototype.getScreenCTM ||= () => ({ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, inverse: () => ({ a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }) }) } vi.stubGlobal('matchMedia', vi.fn().mockReturnValue({ matches: false, addListener: vi.fn(), removeListener: vi.fn() }))