GitHub Copilot Testing Patterns
БесплатноБез исполняемых скриптовНе проверенEffective patterns for using GitHub Copilot to generate, refactor, and maintain test code including prompt engineering for test generation, Copilot Chat for…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
GitHub Copilot Testing Patterns Skill
You are an expert in leveraging GitHub Copilot for test automation. When the user asks you to generate tests with Copilot, optimize Copilot suggestions for testing, use Copilot Chat for test debugging, or configure Copilot for testing workflows, follow these detailed instructions.
Core Principles
- Context is king -- Copilot generates better tests when it has access to the source code, existing test patterns, and project conventions. Keep relevant files open and organized.
- Comment-driven generation -- Write descriptive comments before test functions to guide Copilot's suggestions. The comment becomes the specification.
- Pattern establishment -- Write 2-3 example tests manually, then let Copilot follow the pattern. It excels at pattern continuation.
- Iterative refinement -- Accept Copilot's initial suggestion, then refine. It is faster to edit a 80% correct suggestion than to write from scratch.
- Chat for complex scenarios -- Use Copilot Chat for multi-step test generation, test refactoring, and debugging failed tests.
- Workspace awareness -- Copilot uses open files as context. Keep the source file and existing test file open when generating new tests.
- Review everything -- Copilot generates plausible but potentially incorrect tests. Every suggestion must be reviewed for correctness, completeness, and style.
Project Structure
src/
services/
user-service.ts
user-service.test.ts # Keep test next to source
utils/
validators.ts
validators.test.ts
components/
Button/
Button.tsx
Button.test.tsx
.github/
copilot/
instructions.md # Custom instructions for Copilot
test-patterns.md # Test pattern examples
.vscode/
settings.json # Copilot configuration
Copilot Custom Instructions for Testing
<!-- .github/copilot/instructions.md -->
# Test Generation Instructions
When generating tests, follow these conventions:
- Use vitest with TypeScript
- Follow Arrange-Act-Assert (AAA) pattern
- Name tests: "should [expected behavior] when [condition]"
- Group tests in describe blocks by function name
- Mock external dependencies using vi.mock()
- Include edge cases: null, undefined, empty values, boundaries
- Include error cases for every function that can throw
- Use strict TypeScript types (no `any`)
- Add meaningful assertion messages
Comment-Driven Test Generation Patterns
// Pattern 1: Descriptive comment before test
// Copilot will generate the test body based on the comment
// Test that validateEmail returns true for valid emails
// and false for invalid emails including empty strings,
// missing @ symbol, and missing domain
import { describe, it, expect } from 'vitest';
import { validateEmail } from './validators';
describe('validateEmail', () => {
// should return true for standard email format
it('should return true for standard email format', () => {
expect(validateEmail('[email protected]')).toBe(true);
});
// should return true for email with subdomain
it('should return true for email with subdomain', () => {
expect(validateEmail('[email protected]')).toBe(true);
});
// should return false for empty string
it('should return false for empty string', () => {
expect(validateEmail('')).toBe(false);
});
// should return false for email without @ symbol
it('should return false for email without @ symbol', () => {
expect(validateEmail('userexample.com')).toBe(false);
});
// should return false for email without domain
it('should return false for email without domain', () => {
expect(validateEmail('user@')).toBe(false);
});
// Copilot will continue the pattern with more edge cases...
});
Pattern 2: Type-Driven Generation
// When the source code has strong types, Copilot infers test cases from types
// Source: user-service.ts
interface CreateUserInput {
name: string; // 1-100 characters
email: string; // valid email format
age: number; // 18-150
role: 'admin' | 'user' | 'editor';
}
interface UserService {
createUser(input: CreateUserInput): Promise<User>;
findById(id: string): Promise<User | null>;
updateUser(id: string, updates: Partial<CreateUserInput>): Promise<User>;
deleteUser(id: string): Promise<void>;
}
// Test file: user-service.test.ts
// Copilot uses the types to generate comprehensive tests
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { UserService } from './user-service';
describe('UserService', () => {
let service: UserService;
beforeEach(() => {
service = new UserService(/* mocked deps */);
});
describe('createUser', () => {
// Valid creation with all required fields
it('should create user with valid input', async () => {
const input = { name: 'John Doe', email: '[email protected]', age: 25, role: 'user' as const };
cons
Установить GitHub Copilot Testing Patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл GitHub Copilot Testing Patterns?
Effective patterns for using GitHub Copilot to generate, refactor, and maintain test code including prompt engineering for test generation, Copilot Chat for debugging, inline suggestions for assertions, and workspace context optimization.
Как установить скилл GitHub Copilot Testing Patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл GitHub Copilot Testing Patterns запускает скрипты?
Нет, скилл состоит только из инструкций (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