Claude-session-dashboard testing
Vitest and Playwright testing patterns, conventions, and gotchas for this project.
install
source · Clone the upstream repo
git clone https://github.com/dlupiak/claude-session-dashboard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/dlupiak/claude-session-dashboard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/testing" ~/.claude/skills/dlupiak-claude-session-dashboard-testing && rm -rf "$T"
manifest:
.claude/skills/testing/SKILL.mdsource content
Testing Patterns
Vitest (Unit + Integration)
- Config lives in
(no separate vitest.config)apps/web/vite.config.ts - Run:
fromnpm run testapps/web/ - Run single file:
npx vitest run path/to/file.test.ts
vi.mock Gotcha (IMPORTANT)
vi.mock() is hoisted to the top of the file. You CANNOT reference variables declared above it:
// BAD — will be undefined const mockFn = vi.fn() vi.mock('./module', () => ({ doThing: mockFn })) // GOOD — define inline vi.mock('./module', () => ({ doThing: vi.fn() })) import { doThing } from './module' // Now doThing is the mock — use it for assertions
Rules
- Test behavior, not implementation
- Prefer integration tests over unit tests
- Mock external services, not internal functions
- "close timed out" warning after Vitest is a known nitro issue — ignore
Playwright (E2E)
- Config:
apps/web/playwright.config.ts - Tests:
apps/web/e2e/ - Run:
fromnpm run test:e2eapps/web/ - Use
,page.getByRole()
over CSS selectorspage.getByText()