Testing Strategist
БесплатноБез исполняемых скриптовНе проверенDesign and implement comprehensive testing strategies. Use when setting up tests, choosing test types, implementing TDD, or improving code quality. Covers…
Об этом скилле
Testing Strategist
Test the right things at the right level - write tests that give you confidence to ship.
Core Principle
The Testing Pyramid: 70% unit tests, 20% integration tests, 10% E2E tests.
Tests should be:
- Fast - Run in milliseconds (unit) to seconds (integration) to minutes (E2E)
- Isolated - Test one thing at a time
- Repeatable - Same input = same output
- Self-checking - Pass/fail automatically, no manual verification
- Timely - Written alongside code (or before, with TDD)
The Testing Pyramid
/\
/ \ E2E Tests (10%)
/----\ - Slow, brittle, expensive
/ \ - Test critical user journeys
/--------\ - Example: "User can complete checkout"
/ \
/------------\ Integration Tests (20%)
/ \ - Medium speed, test components together
/----------------\ - Example: "API endpoint returns correct data"
/ \
/--------------------\ Unit Tests (70%)
/______________________\ - Fast, isolated, test functions/components
- Example: "calculateTotal returns sum"
Why This Ratio?
- Unit tests: Fast feedback, pinpoint bugs precisely, easy to maintain
- Integration tests: Ensure components work together, catch interface issues
- E2E tests: Verify actual user flows, catch UI bugs, but slow and brittle
Level 1: Unit Tests (70%)
What to Test
Test individual functions, components, or classes in isolation.
Good candidates:
- ✅ Business logic functions (calculations, validation, transformations)
- ✅ Utility functions (formatDate, parseUrl, etc.)
- ✅ React components (rendering, props, state)
- ✅ Hooks (custom React hooks)
- ✅ Pure functions (same input = same output)
Skip:
- ❌ Third-party libraries (assume they work)
- ❌ Framework internals (React, Next.js)
- ❌ Simple getters/setters with no logic
Unit Test Examples
Testing Business Logic (Jest + TypeScript)
// src/lib/pricing.ts
export function calculateTotal(items: { price: number; quantity: number }[]) {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0)
}
export function applyDiscount(total: number, discountPercent: number) {
if (discountPercent < 0 || discountPercent > 100) {
throw new Error('Invalid discount percentage')
}
return total * (1 - discountPercent / 100)
}
// src/lib/pricing.test.ts
import { calculateTotal, applyDiscount } from './pricing'
describe('calculateTotal', () => {
it('calculates total for single item', () => {
const items = [{ price: 10, quantity: 2 }]
expect(calculateTotal(items)).toBe(20)
})
it('calculates total for multiple items', () => {
const items = [
{ price: 10, quantity: 2 },
{ price: 5, quantity: 3 }
]
expect(calculateTotal(items)).toBe(35)
})
it('returns 0 for empty array', () => {
expect(calculateTotal([])).toBe(0)
})
})
describe('applyDiscount', () => {
it('applies discount correctly', () => {
expect(applyDiscount(100, 20)).toBe(80)
})
it('throws error for invalid discount', () => {
expect(() => applyDiscount(100, -10)).toThrow('Invalid discount')
expect(() => applyDiscount(100, 150)).toThrow('Invalid discount')
})
})
Testing React Components (Jest + React Testing Library)
// src/components/Button.tsx
export function Button({
children,
variant = 'primary',
onClick
}: {
children: React.ReactNode
variant?: 'primary' | 'secondary'
onClick?: () => void
}) {
return (
<button
className={`btn btn-${variant}`}
onClick={onClick}
>
{children}
</button>
)
}
// src/components/Button.test.tsx
import { render, screen, fireEvent } from '@testing-library/react'
import { Button } from './Button'
describe('Button', () => {
it('renders with correct text', () => {
render(<Button>Click me</Button>)
expect(screen.getByText('Click me')).toBeInTheDocument()
})
it('applies primary variant by default', () => {
render(<Button>Click me</Button>)
expect(screen.getByRole('button')).toHaveClass('btn-primary')
})
it('applies secondary variant when specified', () => {
render(<Button variant="secondary">Click me</Button>)
expect(screen.getByRole('button')).toHaveClass('btn-secondary')
})
it('calls onClick when clicked', () => {
const handleClick = jest.fn()
render(<Button onClick={handleClick}>Click me</Button>)
fireEvent.click(screen.getByRole('button'))
expect(handleClick).toHaveBeenCalledTimes(1)
})
})
Testing Custom Hooks
// src/hooks/useCounter.ts
import { useState } from 'react'
export function useCounter(initialValue = 0) {
const [count, setCount] = useState(initialValue)
const increment = () => setCount(c => c + 1)
const decrement = () => setCount(c => c - 1)
const reset = () => setCount(initialValue)
return
Установить Testing Strategist в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл Testing Strategist?
Design and implement comprehensive testing strategies. Use when setting up tests, choosing test types, implementing TDD, or improving code quality. Covers unit tests, integration tests, E2E tests, test-driven development, and testing best practices.
Как установить скилл Testing Strategist?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Testing Strategist запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic