Setup and configure testing infrastructure with Vitest, Playwright, and testing patterns. Use when users need to add tests, configure test runners, implement TDD workflows, or create E2E test suites. Covers unit, integration, and end-to-end testing strategies.
/plugin marketplace add leobrival/topographic-studio-plugins/plugin install code-workflows@topographic-studio-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/patterns/api.test.tsassets/patterns/component.test.tsxassets/patterns/e2e.spec.tsassets/patterns/hook.test.tsassets/playwright/fixtures.tsassets/playwright/playwright.config.tsassets/vitest/setup.tsassets/vitest/test-utils.tsxassets/vitest/vitest.config.tsreferences/mocking.mdreferences/playwright-patterns.mdreferences/testing-best-practices.mdreferences/vitest-config.mdComplete testing infrastructure for modern TypeScript/JavaScript applications.
User request → What type of testing?
│
├─ Unit Tests
│ ├─ Runner?
│ │ ├─ Vitest → Fast, Vite-native, ESM
│ │ ├─ Jest → Mature, wide ecosystem
│ │ └─ Bun test → Ultra-fast, built-in
│ │
│ └─ What to test?
│ ├─ Functions → Pure logic, utilities
│ ├─ Components → React Testing Library
│ ├─ Hooks → @testing-library/react-hooks
│ └─ API handlers → MSW for mocking
│
├─ Integration Tests
│ ├─ Database → Test containers, in-memory
│ ├─ API → Supertest, actual endpoints
│ └─ Services → Real dependencies
│
├─ E2E Tests
│ ├─ Playwright → Cross-browser, fast
│ ├─ Cypress → Great DX, dashboard
│ └─ What to test?
│ ├─ User flows → Critical paths
│ ├─ Visual regression → Screenshots
│ └─ Accessibility → axe-core
│
└─ Test Strategy
├─ TDD → Red-green-refactor
├─ Coverage → Istanbul/c8
└─ CI → GitHub Actions integration
# Install
pnpm add -D vitest @vitest/coverage-v8 @vitest/ui
# With React
pnpm add -D @testing-library/react @testing-library/jest-dom jsdom
// vitest.config.ts
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./src/test/setup.ts"],
include: ["src/**/*.{test,spec}.{ts,tsx}"],
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
exclude: ["node_modules/", "src/test/"],
},
},
});
# Install
pnpm add -D @playwright/test
npx playwright install
// playwright.config.ts
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./e2e",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: "html",
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry",
screenshot: "only-on-failure",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
{ name: "webkit", use: { ...devices["Desktop Safari"] } },
],
webServer: {
command: "pnpm dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
});
// utils/format.test.ts
import { describe, it, expect } from "vitest";
import { formatCurrency, formatDate } from "./format";
describe("formatCurrency", () => {
it("formats USD correctly", () => {
expect(formatCurrency(1234.56, "USD")).toBe("$1,234.56");
});
it("handles zero", () => {
expect(formatCurrency(0, "USD")).toBe("$0.00");
});
it("handles negative values", () => {
expect(formatCurrency(-50, "USD")).toBe("-$50.00");
});
});
// components/Button.test.tsx
import { render, screen, fireEvent } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { Button } from "./Button";
describe("Button", () => {
it("renders with text", () => {
render(<Button>Click me</Button>);
expect(screen.getByRole("button")).toHaveTextContent("Click me");
});
it("calls onClick when clicked", () => {
const handleClick = vi.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByRole("button"));
expect(handleClick).toHaveBeenCalledTimes(1);
});
it("is disabled when loading", () => {
render(<Button loading>Submit</Button>);
expect(screen.getByRole("button")).toBeDisabled();
});
});
// e2e/auth.spec.ts
import { test, expect } from "@playwright/test";
test.describe("Authentication", () => {
test("user can login", async ({ page }) => {
await page.goto("/login");
await page.fill('[name="email"]', "user@example.com");
await page.fill('[name="password"]', "password123");
await page.click('button[type="submit"]');
await expect(page).toHaveURL("/dashboard");
await expect(page.locator("h1")).toContainText("Welcome");
});
test("shows error for invalid credentials", async ({ page }) => {
await page.goto("/login");
await page.fill('[name="email"]', "wrong@example.com");
await page.fill('[name="password"]', "wrongpass");
await page.click('button[type="submit"]');
await expect(page.locator('[role="alert"]')).toContainText("Invalid");
});
});
| Test Type | Coverage | Speed | Confidence |
|---|---|---|---|
| Unit | High (70-80%) | Fast | Low-Medium |
| Integration | Medium (15-20%) | Medium | Medium-High |
| E2E | Low (5-10%) | Slow | High |
should return empty array when no itemsThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.