Skip to content
Sheetwrite

Sheetwrite / Documentation

installCanvasTestStubs@sheetwrite/core/testing

Install the canvas + layout stubs a DOM test environment (jsdom/happy-dom) needs before createGrid can mount — without them the renderer throws "Sheetwrite: 2D canvas context is unavailable".

Install the canvas + layout stubs a DOM test environment (jsdom/happy-dom) needs before createGrid can mount — without them the renderer throws "Sheetwrite: 2D canvas context is unavailable". Returns a restore function that undoes every patch.

The installed getContext("2d") returns a per-canvas RecordingContext2D; re-request it from a mounted canvas to assert paint activity. Nothing is painted — assert grid STATE, not pixels. Test-only: never import from production code.

Declaration

function installCanvasTestStubs(
options?: CanvasTestStubOptions,
): () => void