[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79CMRFK344G074F6F91PSPR":3,"skill-same:01M79CMRFK344G074F6F91PSPR":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M79CMRFK344G074F6F91PSPR","write-unit-tests",null,"Writing unit and integration tests for the tldraw SDK. Use when creating new tests, adding test coverage, or fixing failing tests in packages\u002Feditor or packages\u002Ftldraw. Covers Vitest patterns, TestEditor usage, and test file organization.","shubhamraheja\u002Fskill-inject-open-weight","shubhamraheja","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78694998?v=4","01M79CD4796MK5E8XJXQB9A3HN","Shubham Raheja","01M79CD488EPAZNQJ4BKWEWWKK",0,"MIT","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwrite-unit-tests\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: write-unit-tests\ndescription: \"Writing unit and integration tests for the tldraw SDK. Use when creating new tests, adding test coverage, or fixing failing tests in packages\u002Feditor or packages\u002Ftldraw. Covers Vitest patterns, TestEditor usage, and test file organization.\"\n---\n\n# Writing tests\n\nUnit and integration tests use Vitest. Tests run from workspace directories, not the repo root.\n\n## Test file locations\n\n**Unit tests** - alongside source files:\n\n```\npackages\u002Feditor\u002Fsrc\u002Flib\u002Fprimitives\u002FVec.ts\npackages\u002Feditor\u002Fsrc\u002Flib\u002Fprimitives\u002FVec.test.ts  # Same directory\n```\n\n**Integration tests** - in `src\u002Ftest\u002F` directory:\n\n```\npackages\u002Ftldraw\u002Fsrc\u002Ftest\u002FSelectTool.test.ts\npackages\u002Ftldraw\u002Fsrc\u002Ftest\u002Fcommands\u002FcreateShape.test.ts\n```\n\n**Shape\u002Ftool tests** - alongside the implementation:\n\n```\npackages\u002Ftldraw\u002Fsrc\u002Flib\u002Fshapes\u002Farrow\u002FArrowShapeUtil.test.ts\npackages\u002Ftldraw\u002Fsrc\u002Flib\u002Fshapes\u002Farrow\u002FArrowShapeTool.test.ts\n```\n\n## Which workspace to test in\n\n- **packages\u002Feditor**: Core primitives, geometry, managers, base editor functionality\n- **packages\u002Ftldraw**: Anything needing default shapes\u002Ftools (most integration tests)\n\n```bash\ncd packages\u002Ftldraw && yarn test run\ncd packages\u002Ftldraw && yarn test run --grep \"SelectTool\"\n```\n\n## TestEditor vs Editor\n\nUse `TestEditor` for integration tests (includes default shapes\u002Ftools):\n\n```typescript\nimport { createShapeId } from '@tldraw\u002Feditor'\nimport { TestEditor } from '.\u002FTestEditor'\n\nlet editor: TestEditor\n\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.selectAll().deleteShapes(editor.getSelectedShapeIds())\n})\n\nafterEach(() => {\n\teditor?.dispose()\n})\n```\n\nUse raw `Editor` when testing editor setup or custom configurations:\n\n```typescript\nimport { Editor, createTLStore } from '@tldraw\u002Feditor'\n\nbeforeEach(() => {\n\teditor = new Editor({\n\t\tshapeUtils: [CustomShape],\n\t\tbindingUtils: [],\n\t\ttools: [CustomTool],\n\t\tstore: createTLStore({ shapeUtils: [CustomShape], bindingUtils: [] }),\n\t\tgetContainer: () => document.body,\n\t})\n})\n```\n\n## Common TestEditor methods\n\n```typescript\n\u002F\u002F Pointer simulation\neditor.pointerDown(x, y, options?)\neditor.pointerMove(x, y, options?)\neditor.pointerUp(x, y, options?)\neditor.click(x, y, shapeId?)\neditor.doubleClick(x, y, shapeId?)\n\n\u002F\u002F Keyboard simulation\neditor.keyDown(key, options?)\neditor.keyUp(key, options?)\n\n\u002F\u002F State assertions\neditor.expectToBeIn('select.idle')\neditor.expectToBeIn('select.crop.idle')\n\n\u002F\u002F Shape assertions\neditor.expectShapeToMatch({ id, x, y, props: { ... } })\n\n\u002F\u002F Shape operations\neditor.createShapes([{ id, type, x, y, props }])\neditor.updateShapes([{ id, type, props }])\neditor.getShape(id)\neditor.select(id1, id2)\neditor.selectAll()\neditor.selectNone()\neditor.getSelectedShapeIds()\neditor.getOnlySelectedShape()\n\n\u002F\u002F Tool operations\neditor.setCurrentTool('arrow')\neditor.getCurrentToolId()\n\n\u002F\u002F Undo\u002Fredo\neditor.undo()\neditor.redo()\n```\n\n## Pointer event options\n\n```typescript\neditor.pointerDown(100, 100, {\n\ttarget: 'shape', \u002F\u002F 'canvas' | 'shape' | 'handle' | 'selection'\n\tshape: editor.getShape(id),\n})\n\neditor.pointerDown(150, 300, {\n\ttarget: 'selection',\n\thandle: 'bottom', \u002F\u002F 'top' | 'bottom' | 'left' | 'right' | corners\n})\n\neditor.doubleClick(550, 550, {\n\ttarget: 'selection',\n\thandle: 'bottom_right',\n})\n```\n\n## Setup patterns\n\n### Standard setup with shape IDs\n\n```typescript\nconst ids = {\n\tbox1: createShapeId('box1'),\n\tbox2: createShapeId('box2'),\n\tarrow1: createShapeId('arrow1'),\n}\n\nvi.useFakeTimers()\n\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.selectAll().deleteShapes(editor.getSelectedShapeIds())\n\teditor.createShapes([\n\t\t{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } },\n\t\t{ id: ids.box2, type: 'geo', x: 300, y: 300, props: { w: 100, h: 100 } },\n\t])\n})\n\nafterEach(() => {\n\teditor?.dispose()\n})\n```\n\n### Reusable props\n\n```typescript\nconst imageProps = {\n\tassetId: null,\n\tplaying: true,\n\turl: '',\n\tw: 1200,\n\th: 800,\n}\n\neditor.createShapes([\n\t{ id: ids.imageA, type: 'image', x: 100, y: 100, props: imageProps },\n\t{ id: ids.imageB, type: 'image', x: 500, y: 500, props: { ...imageProps, w: 600, h: 400 } },\n])\n```\n\n### Helper functions\n\n```typescript\nfunction arrow(id = ids.arrow1) {\n\treturn editor.getShape(id) as TLArrowShape\n}\n\nfunction bindings(id = ids.arrow1) {\n\treturn getArrowBindings(editor, arrow(id))\n}\n```\n\n## Mocking with vi.spyOn\n\n```typescript\n\u002F\u002F Mock return value\nvi.spyOn(editor, 'getIsReadonly').mockReturnValue(true)\n\n\u002F\u002F Mock implementation\nconst isHiddenSpy = vi.spyOn(editor, 'isShapeHidden')\nisHiddenSpy.mockImplementation((shape) => shape.id === ids.hiddenShape)\n\n\u002F\u002F Verify calls\nconst spy = vi.spyOn(editor, 'setSelectedShapes')\neditor.selectAll()\nexpect(spy).toHaveBeenCalled()\nexpect(spy).not.toHaveBeenCalled()\n\n\u002F\u002F Always restore\nisHiddenSpy.mockRestore()\n```\n\n## Fake timers\n\n```typescript\nvi.useFakeTimers()\n\n\u002F\u002F Mock animation frame\nwindow.requestAnimationFrame = (cb) => setTimeout(cb, 1000 \u002F 60)\nwindow.cancelAnimationFrame = (id) => clearTimeout(id)\n\nit('handles animation', () => {\n\teditor.alignShapes(editor.getSelectedShapeIds(), 'right')\n\tvi.advanceTimersByTime(1000)\n\t\u002F\u002F Assert after animation completes\n})\n```\n\n## Assertions\n\n### Shape matching\n\n```typescript\n\u002F\u002F Partial matching (most common)\nexpect(editor.getShape(id)).toMatchObject({\n\ttype: 'geo',\n\tx: 100,\n\tprops: { w: 100 },\n})\n\neditor.expectShapeToMatch({\n\tid: ids.box1,\n\tx: 350,\n\ty: 350,\n})\n\n\u002F\u002F Floating point matching (custom matcher)\nexpect(result).toCloselyMatchObject({\n\tprops: { normalizedAnchor: { x: 0.5, y: 0.75 } },\n})\n```\n\n### Array assertions\n\n```typescript\nexpect(editor.getSelectedShapeIds()).toMatchObject([ids.box1])\nexpect(Array.from(selectedIds).sort()).toEqual([id1, id2, id3].sort())\nexpect(shapes).toContain('geo')\nexpect(shapes).not.toContain(ids.lockedShape)\n```\n\n### State assertions\n\n```typescript\neditor.expectToBeIn('select.idle')\neditor.expectToBeIn('select.brushing')\neditor.expectToBeIn('select.crop.idle')\n```\n\n## Testing undo\u002Fredo\n\n```typescript\nit('handles undo\u002Fredo', () => {\n\teditor.doubleClick(550, 550, ids.image)\n\teditor.expectToBeIn('select.crop.idle')\n\n\teditor.updateShape({ id: ids.image, type: 'image', props: { crop: newCrop } })\n\n\teditor.undo()\n\teditor.expectToBeIn('select.crop.idle')\n\texpect(editor.getShape(ids.image)!.props.crop).toMatchObject(originalCrop)\n\n\teditor.redo()\n\texpect(editor.getShape(ids.image)!.props.crop).toMatchObject(newCrop)\n})\n```\n\n## Testing TypeScript types\n\n```typescript\nit('Uses typescript generics', () => {\n\texpect(() => {\n\t\t\u002F\u002F @ts-expect-error - wrong props type\n\t\teditor.createShape({ id, type: 'geo', props: { w: 'OH NO' } })\n\n\t\t\u002F\u002F @ts-expect-error - unknown prop\n\t\teditor.createShape({ id, type: 'geo', props: { foo: 'bar' } })\n\n\t\t\u002F\u002F Valid\n\t\teditor.createShape\u003CTLGeoShape>({ id, type: 'geo', props: { w: 100 } })\n\t}).toThrow()\n})\n```\n\n## Testing custom shapes\n\n```typescript\ndeclare module '@tldraw\u002Ftlschema' {\n\texport interface TLGlobalShapePropsMap {\n\t\t'my-custom-shape': { w: number; h: number; text: string | undefined }\n\t}\n}\n\nclass CustomShape extends ShapeUtil\u003CICustomShape> {\n\tstatic override type = 'my-custom-shape'\n\tstatic override props: RecordProps\u003CICustomShape> = {\n\t\tw: T.number,\n\t\th: T.number,\n\t\ttext: T.string.optional(),\n\t}\n\tgetDefaultProps() {\n\t\treturn { w: 200, h: 200, text: '' }\n\t}\n\tgetGeometry(shape) {\n\t\treturn new Rectangle2d({ width: shape.props.w, height: shape.props.h })\n\t}\n\tindicator() {}\n\tcomponent() {}\n}\n```\n\n## Testing side effects\n\n```typescript\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.sideEffects.registerAfterChangeHandler('instance_page_state', (prev, next) => {\n\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\u002F\u002F Handle state change\n\t\t}\n\t})\n})\n```\n\n## Testing events\n\n```typescript\nit('emits wheel events', () => {\n\tconst handler = vi.fn()\n\teditor.on('event', handler)\n\n\teditor.dispatch({\n\t\ttype: 'wheel',\n\t\tname: 'wheel',\n\t\tdelta: { x: 0, y: 10, z: 0 },\n\t\tpoint: { x: 100, y: 100, z: 1 },\n\t\tshiftKey: false,\n\t\t\u002F\u002F ... other modifiers\n\t})\n\teditor.emit('tick', 16) \u002F\u002F Flush batched events\n\n\texpect(handler).toHaveBeenCalledWith(expect.objectContaining({ name: 'wheel' }))\n})\n```\n\n## Method chaining\n\n```typescript\neditor\n\t.expectToBeIn('select.idle')\n\t.select(ids.imageA, ids.imageB)\n\t.doubleClick(550, 550, { target: 'selection', handle: 'bottom_right' })\n\t.expectToBeIn('select.idle')\n\neditor.setCurrentTool('arrow').pointerDown(0, 0).pointerMove(100, 100).pointerUp()\n```\n\n## Running tests\n\n```bash\ncd packages\u002Ftldraw && yarn test run\ncd packages\u002Ftldraw && yarn test run --grep \"arrow\"\ncd packages\u002Feditor && yarn test run --grep \"Vec\"\n\n# Watch mode\ncd packages\u002Ftldraw && yarn test\n```\n\n## Key patterns summary\n\n- Use `createShapeId()` for shape IDs\n- Use `vi.useFakeTimers()` for time-dependent behavior\n- Clear shapes in `beforeEach`, dispose in `afterEach`\n- Test in `packages\u002Ftldraw` for shapes\u002Ftools\n- Use `expectToBeIn()` for state machine assertions\n- Use `toMatchObject()` for partial matching\n- Use `toCloselyMatchObject()` for floating point values\n- Mock with `vi.spyOn()` and always `mockRestore()`\n","# Writing tests\n\nUnit and integration tests use Vitest. Tests run from workspace directories, not the repo root.\n\n## Test file locations\n\n**Unit tests** - alongside source files:\n\n```\npackages\u002Feditor\u002Fsrc\u002Flib\u002Fprimitives\u002FVec.ts\npackages\u002Feditor\u002Fsrc\u002Flib\u002Fprimitives\u002FVec.test.ts  # Same directory\n```\n\n**Integration tests** - in `src\u002Ftest\u002F` directory:\n\n```\npackages\u002Ftldraw\u002Fsrc\u002Ftest\u002FSelectTool.test.ts\npackages\u002Ftldraw\u002Fsrc\u002Ftest\u002Fcommands\u002FcreateShape.test.ts\n```\n\n**Shape\u002Ftool tests** - alongside the implementation:\n\n```\npackages\u002Ftldraw\u002Fsrc\u002Flib\u002Fshapes\u002Farrow\u002FArrowShapeUtil.test.ts\npackages\u002Ftldraw\u002Fsrc\u002Flib\u002Fshapes\u002Farrow\u002FArrowShapeTool.test.ts\n```\n\n## Which workspace to test in\n\n- **packages\u002Feditor**: Core primitives, geometry, managers, base editor functionality\n- **packages\u002Ftldraw**: Anything needing default shapes\u002Ftools (most integration tests)\n\n```bash\ncd packages\u002Ftldraw && yarn test run\ncd packages\u002Ftldraw && yarn test run --grep \"SelectTool\"\n```\n\n## TestEditor vs Editor\n\nUse `TestEditor` for integration tests (includes default shapes\u002Ftools):\n\n```typescript\nimport { createShapeId } from '@tldraw\u002Feditor'\nimport { TestEditor } from '.\u002FTestEditor'\n\nlet editor: TestEditor\n\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.selectAll().deleteShapes(editor.getSelectedShapeIds())\n})\n\nafterEach(() => {\n\teditor?.dispose()\n})\n```\n\nUse raw `Editor` when testing editor setup or custom configurations:\n\n```typescript\nimport { Editor, createTLStore } from '@tldraw\u002Feditor'\n\nbeforeEach(() => {\n\teditor = new Editor({\n\t\tshapeUtils: [CustomShape],\n\t\tbindingUtils: [],\n\t\ttools: [CustomTool],\n\t\tstore: createTLStore({ shapeUtils: [CustomShape], bindingUtils: [] }),\n\t\tgetContainer: () => document.body,\n\t})\n})\n```\n\n## Common TestEditor methods\n\n```typescript\n\u002F\u002F Pointer simulation\neditor.pointerDown(x, y, options?)\neditor.pointerMove(x, y, options?)\neditor.pointerUp(x, y, options?)\neditor.click(x, y, shapeId?)\neditor.doubleClick(x, y, shapeId?)\n\n\u002F\u002F Keyboard simulation\neditor.keyDown(key, options?)\neditor.keyUp(key, options?)\n\n\u002F\u002F State assertions\neditor.expectToBeIn('select.idle')\neditor.expectToBeIn('select.crop.idle')\n\n\u002F\u002F Shape assertions\neditor.expectShapeToMatch({ id, x, y, props: { ... } })\n\n\u002F\u002F Shape operations\neditor.createShapes([{ id, type, x, y, props }])\neditor.updateShapes([{ id, type, props }])\neditor.getShape(id)\neditor.select(id1, id2)\neditor.selectAll()\neditor.selectNone()\neditor.getSelectedShapeIds()\neditor.getOnlySelectedShape()\n\n\u002F\u002F Tool operations\neditor.setCurrentTool('arrow')\neditor.getCurrentToolId()\n\n\u002F\u002F Undo\u002Fredo\neditor.undo()\neditor.redo()\n```\n\n## Pointer event options\n\n```typescript\neditor.pointerDown(100, 100, {\n\ttarget: 'shape', \u002F\u002F 'canvas' | 'shape' | 'handle' | 'selection'\n\tshape: editor.getShape(id),\n})\n\neditor.pointerDown(150, 300, {\n\ttarget: 'selection',\n\thandle: 'bottom', \u002F\u002F 'top' | 'bottom' | 'left' | 'right' | corners\n})\n\neditor.doubleClick(550, 550, {\n\ttarget: 'selection',\n\thandle: 'bottom_right',\n})\n```\n\n## Setup patterns\n\n### Standard setup with shape IDs\n\n```typescript\nconst ids = {\n\tbox1: createShapeId('box1'),\n\tbox2: createShapeId('box2'),\n\tarrow1: createShapeId('arrow1'),\n}\n\nvi.useFakeTimers()\n\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.selectAll().deleteShapes(editor.getSelectedShapeIds())\n\teditor.createShapes([\n\t\t{ id: ids.box1, type: 'geo', x: 100, y: 100, props: { w: 100, h: 100 } },\n\t\t{ id: ids.box2, type: 'geo', x: 300, y: 300, props: { w: 100, h: 100 } },\n\t])\n})\n\nafterEach(() => {\n\teditor?.dispose()\n})\n```\n\n### Reusable props\n\n```typescript\nconst imageProps = {\n\tassetId: null,\n\tplaying: true,\n\turl: '',\n\tw: 1200,\n\th: 800,\n}\n\neditor.createShapes([\n\t{ id: ids.imageA, type: 'image', x: 100, y: 100, props: imageProps },\n\t{ id: ids.imageB, type: 'image', x: 500, y: 500, props: { ...imageProps, w: 600, h: 400 } },\n])\n```\n\n### Helper functions\n\n```typescript\nfunction arrow(id = ids.arrow1) {\n\treturn editor.getShape(id) as TLArrowShape\n}\n\nfunction bindings(id = ids.arrow1) {\n\treturn getArrowBindings(editor, arrow(id))\n}\n```\n\n## Mocking with vi.spyOn\n\n```typescript\n\u002F\u002F Mock return value\nvi.spyOn(editor, 'getIsReadonly').mockReturnValue(true)\n\n\u002F\u002F Mock implementation\nconst isHiddenSpy = vi.spyOn(editor, 'isShapeHidden')\nisHiddenSpy.mockImplementation((shape) => shape.id === ids.hiddenShape)\n\n\u002F\u002F Verify calls\nconst spy = vi.spyOn(editor, 'setSelectedShapes')\neditor.selectAll()\nexpect(spy).toHaveBeenCalled()\nexpect(spy).not.toHaveBeenCalled()\n\n\u002F\u002F Always restore\nisHiddenSpy.mockRestore()\n```\n\n## Fake timers\n\n```typescript\nvi.useFakeTimers()\n\n\u002F\u002F Mock animation frame\nwindow.requestAnimationFrame = (cb) => setTimeout(cb, 1000 \u002F 60)\nwindow.cancelAnimationFrame = (id) => clearTimeout(id)\n\nit('handles animation', () => {\n\teditor.alignShapes(editor.getSelectedShapeIds(), 'right')\n\tvi.advanceTimersByTime(1000)\n\t\u002F\u002F Assert after animation completes\n})\n```\n\n## Assertions\n\n### Shape matching\n\n```typescript\n\u002F\u002F Partial matching (most common)\nexpect(editor.getShape(id)).toMatchObject({\n\ttype: 'geo',\n\tx: 100,\n\tprops: { w: 100 },\n})\n\neditor.expectShapeToMatch({\n\tid: ids.box1,\n\tx: 350,\n\ty: 350,\n})\n\n\u002F\u002F Floating point matching (custom matcher)\nexpect(result).toCloselyMatchObject({\n\tprops: { normalizedAnchor: { x: 0.5, y: 0.75 } },\n})\n```\n\n### Array assertions\n\n```typescript\nexpect(editor.getSelectedShapeIds()).toMatchObject([ids.box1])\nexpect(Array.from(selectedIds).sort()).toEqual([id1, id2, id3].sort())\nexpect(shapes).toContain('geo')\nexpect(shapes).not.toContain(ids.lockedShape)\n```\n\n### State assertions\n\n```typescript\neditor.expectToBeIn('select.idle')\neditor.expectToBeIn('select.brushing')\neditor.expectToBeIn('select.crop.idle')\n```\n\n## Testing undo\u002Fredo\n\n```typescript\nit('handles undo\u002Fredo', () => {\n\teditor.doubleClick(550, 550, ids.image)\n\teditor.expectToBeIn('select.crop.idle')\n\n\teditor.updateShape({ id: ids.image, type: 'image', props: { crop: newCrop } })\n\n\teditor.undo()\n\teditor.expectToBeIn('select.crop.idle')\n\texpect(editor.getShape(ids.image)!.props.crop).toMatchObject(originalCrop)\n\n\teditor.redo()\n\texpect(editor.getShape(ids.image)!.props.crop).toMatchObject(newCrop)\n})\n```\n\n## Testing TypeScript types\n\n```typescript\nit('Uses typescript generics', () => {\n\texpect(() => {\n\t\t\u002F\u002F @ts-expect-error - wrong props type\n\t\teditor.createShape({ id, type: 'geo', props: { w: 'OH NO' } })\n\n\t\t\u002F\u002F @ts-expect-error - unknown prop\n\t\teditor.createShape({ id, type: 'geo', props: { foo: 'bar' } })\n\n\t\t\u002F\u002F Valid\n\t\teditor.createShape\u003CTLGeoShape>({ id, type: 'geo', props: { w: 100 } })\n\t}).toThrow()\n})\n```\n\n## Testing custom shapes\n\n```typescript\ndeclare module '@tldraw\u002Ftlschema' {\n\texport interface TLGlobalShapePropsMap {\n\t\t'my-custom-shape': { w: number; h: number; text: string | undefined }\n\t}\n}\n\nclass CustomShape extends ShapeUtil\u003CICustomShape> {\n\tstatic override type = 'my-custom-shape'\n\tstatic override props: RecordProps\u003CICustomShape> = {\n\t\tw: T.number,\n\t\th: T.number,\n\t\ttext: T.string.optional(),\n\t}\n\tgetDefaultProps() {\n\t\treturn { w: 200, h: 200, text: '' }\n\t}\n\tgetGeometry(shape) {\n\t\treturn new Rectangle2d({ width: shape.props.w, height: shape.props.h })\n\t}\n\tindicator() {}\n\tcomponent() {}\n}\n```\n\n## Testing side effects\n\n```typescript\nbeforeEach(() => {\n\teditor = new TestEditor()\n\teditor.sideEffects.registerAfterChangeHandler('instance_page_state', (prev, next) => {\n\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\u002F\u002F Handle state change\n\t\t}\n\t})\n})\n```\n\n## Testing events\n\n```typescript\nit('emits wheel events', () => {\n\tconst handler = vi.fn()\n\teditor.on('event', handler)\n\n\teditor.dispatch({\n\t\ttype: 'wheel',\n\t\tname: 'wheel',\n\t\tdelta: { x: 0, y: 10, z: 0 },\n\t\tpoint: { x: 100, y: 100, z: 1 },\n\t\tshiftKey: false,\n\t\t\u002F\u002F ... other modifiers\n\t})\n\teditor.emit('tick', 16) \u002F\u002F Flush batched events\n\n\texpect(handler).toHaveBeenCalledWith(expect.objectContaining({ name: 'wheel' }))\n})\n```\n\n## Method chaining\n\n```typescript\neditor\n\t.expectToBeIn('select.idle')\n\t.select(ids.imageA, ids.imageB)\n\t.doubleClick(550, 550, { target: 'selection', handle: 'bottom_right' })\n\t.expectToBeIn('select.idle')\n\neditor.setCurrentTool('arrow').pointerDown(0, 0).pointerMove(100, 100).pointerUp()\n```\n\n## Running tests\n\n```bash\ncd packages\u002Ftldraw && yarn test run\ncd packages\u002Ftldraw && yarn test run --grep \"arrow\"\ncd packages\u002Feditor && yarn test run --grep \"Vec\"\n\n# Watch mode\ncd packages\u002Ftldraw && yarn test\n```\n\n## Key patterns summary\n\n- Use `createShapeId()` for shape IDs\n- Use `vi.useFakeTimers()` for time-dependent behavior\n- Clear shapes in `beforeEach`, dispose in `afterEach`\n- Test in `packages\u002Ftldraw` for shapes\u002Ftools\n- Use `expectToBeIn()` for state machine assertions\n- Use `toMatchObject()` for partial matching\n- Use `toCloselyMatchObject()` for floating point values\n- Mock with `vi.spyOn()` and always `mockRestore()`\n",{"name":5,"description":7},"main","2920d4cad6ebed499bad2dd44f716e32e8ae2fd3","data\u002Fskills\u002Fwrite-unit-tests","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight","https:\u002F\u002Fgithub.com\u002Fshubhamraheja","Master's student @ University of Tübingen","2026-07-20 07:25:27",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add shubhamraheja\u002Fskill-inject-open-weight --skill write-unit-tests",{"tool":37,"command":38},"bunx","bunx skills add shubhamraheja\u002Fskill-inject-open-weight --skill write-unit-tests",{"tool":40,"command":41},"pnpm","pnpm dlx skills add shubhamraheja\u002Fskill-inject-open-weight --skill write-unit-tests","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwrite-unit-tests\u002FSKILL.md",true,[],[46,55,62,69,76,83],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":51,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M79CMKK71S2D21EWTVKZ6AQJ","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M79CMHKR6J5W8ATM3FKNSA0Z","template-skill","Replace with description of the skill and when Claude should use it.","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Ftemplate-skill\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M79CMG5M3NJWCJ3X3T12AFS3","system-info","Get system information using executable scripts","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fsystem-info\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M79CMC6HD07SATZ1HPSCZRD0","stripe-integration","Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fstripe-integration\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M79CM7GQ51BRPZTV5BQ5B2E4","sql-optimization-patterns","Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fsql-optimization-patterns\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":50,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M79CM2SG5117KW7W2YGVRS68","slack-gif-creator","Toolkit for creating animated GIFs optimized for Slack, with validators for size constraints and composable animation primitives. This skill applies when users request animated GIFs or emoji animations for Slack from descriptions like \"make me a GIF for Slack of X doing Y\".","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fslack-gif-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fshubhamraheja\u002Fskill-inject-open-weight\u002Fblob\u002Fmain\u002Fdata\u002Fskills\u002Fslack-gif-creator\u002FSKILL.md",[],[]]