Changelog - 2026-11-06
Test fakes for the browser APIs the hooks use
New FeatureIn one line. @venizia/ardor/testing now holds a fake of IntersectionObserver, of matchMedia, of Storage and of navigator.clipboard, next to FakeResizeObserver, so a test does not copy ARDOR's own stubs.
ts
import { FakeIntersectionObserver, FakeStorage } from '@venizia/ardor/testing';
declare const element: Element; // the element the component under test observes
const restoreObserver = FakeIntersectionObserver.install();
const storage = new FakeStorage();
const restoreStorage = storage.install();
// render the component, then:
FakeIntersectionObserver.flush({ element, isIntersecting: true });
storage.failWrites = true; // the next write throws QuotaExceededError
restoreStorage();
restoreObserver();What changed
- Four new fakes.
FakeIntersectionObserver(install,flush,settlefor the first report,live,created),FakeMatchMedia(install,set,queries,listenerCount),FakeStorage(install,failReads,failListing,failWrites,writes) andFakeClipboard(install,written,text,isDenied). See Testing. FakeResizeObservershows what it holds.FakeResizeObserver.alllists the observers a test created; each hascallback,targets,options,unobservedandisDisconnected. It was private before.- They reach
windowtoo.installalso puts the fake onwindowwhere that is another object than the global, as in happy-dom, souseMediaQueryand code that readswindow.localStoragemeet it. - A second import path. The fakes live in
@venizia/ardor-kernel/testing, which@venizia/ardor/testingre-exports. A project that uses only the kernel imports them from there. The kernel's main entry does not include them.
Who is affected
- An app with its own stubs of these APIs. You can replace them with the fakes; nothing forces you to.
- All other apps. No action needed.