myscript/iinkts/testing-patterns
Claude Code and agent skill by myscript/iinkts
- community
Checking that the SKILL.md file is still in the repository.
Guide for writing and running tests in iinkTS. Use when adding unit tests with Jest, creating E2E tests with Playwright, or understanding mocking patterns for Canvas/WebSocket.
Install
npx vskill@latest install myscript/iinkts/testing-patternsSKILL.md
Testing Patterns Skill
Test Structure
Unit Tests (Jest)
Location: test/unit/{module}/{Class}.test.ts
Example structure:
E2E Tests (Playwright)
Location: test/examples/{canvas|interactive-canvas|interactive-canvas-ssr|custom-rendering}/{feature}.test.js — mirrors the examples/ subdirectory (not .spec.ts, real files are .test.js).
Example structure:
Mocking Patterns
Canvas Mocking
Canvas is mocked via jest-canvas-mock:
Auto-loaded: Configured in test/unit/jest.config.js
WebSocket Mocking
jest-websocket-mock for unit tests:
Custom mocks in test/unit/__mocks__/:
ServerWebSocketMock/ServerWebSocketSSRMock- Full WebSocket server simulationWebSocketSSRClientMock- subclass ofWebSocketSSRClientfor testsEventMock/CanvasEventMock- event class mocks
Canvas Instance Mocking
Pre-built canvas mocks in test/unit/__mocks__/:
Fetch Mocking
Use jest-fetch-mock:
Test Helpers & Utilities
Location: test/unit/helpers.ts
Available Helper Functions
Test Data Builders
buildStrokeV2 - Create a TStroke with realistic data (from test/unit/helpers.ts):
buildStroke - Create basic Stroke for simple tests:
Test Configuration
Default test values used in helpers:
DefaultPenStyle- Standard pen stylingDefaultStyle- Base symbol styling- Default DPI: 96
- Default pointer pressure: 0.5
Running Tests
Unit Tests
Coverage threshold: 75% for branches, functions, lines, statements (enforced in CI).
E2E Tests
Test Data
Location: test/unit/__dataset__/ — real files:
configuration.dataset.ts— sample client configs (WebSocketSSRClientTextConfiguration,WebSocketSSRClientMathConfiguration,HTTPClientV1TextConfiguration, ...)exports.dataset.ts— sample JIIX export payloads (jiixText,jiixMathDuplicateStrokes)jiix.dataset.ts— sample JIIX documents (hTextJIIX,rectangleJIIX,circleJIIX)
Usage:
Test Configuration
Jest Config
Key settings in test/unit/jest.config.js:
testEnvironment: "jsdom"- Browser-like environmentpreset: "ts-jest"- TypeScript supportmoduleNameMapper- Web worker path resolutionsetupFiles- Canvas mock, TextEncoder polyfilltransform- CSS and SVG transforms
Playwright Config
Key settings in test/examples/playwright.config.js:
- Browser targets: Chromium, Firefox, WebKit
- Base URL:
http://localhost:8000 - Screenshot on failure
- Video recording
Common Test Scenarios
Testing Canvas Initialization
Testing Stroke Drawing
Testing Recognition
Testing Anti-Patterns
❌ Don't test implementation details (private methods) ❌ Don't create brittle tests dependent on exact HTML structure ❌ Don't forget to clean up (destroy editors, close WebSockets) ❌ Don't use real network calls (always mock) ❌ Don't share state between tests (use beforeEach)
Debugging Tests
Jest Debugging
Playwright Debugging
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/testing-patterns/SKILL.md
Popularity
- Repository stars
- 98
- Repository forks
- 16
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/myscript/iinkts/testing-patterns)