write-unit-tests
Installation
SKILL.md
Writing tests
Unit and integration tests use Vitest and run from workspace directories, not the repo root.
Read a neighboring test before writing a new one — the existing suites are the specification for how we test, and they stay current in a way prose can't. Good starting points:
packages/tldraw/src/test/SelectTool.test.ts— tool state machine assertionspackages/tldraw/src/test/resizing.test.ts— pointer-driven interaction with handlespackages/tldraw/src/lib/shapes/arrow/ArrowShapeUtil.test.ts— shape util plus bindingspackages/editor/src/lib/editor/managers/ClickManager/ClickManager.test.ts— a UI-free managerpackages/editor/src/lib/primitives/Vec.test.ts— a plain primitive
For the available TestEditor methods, read the class itself rather than a list here: packages/tldraw/src/test/TestEditor.ts.
Which workspace
packages/editor— core primitives, geometry, managers, base editor behavior that must not depend on default shapes or UI.packages/tldraw— anything needing default shapes or tools, which is most integration tests.