Jest testing patterns, factory functions, mocking strategies, and TDD workflow. Use when writing unit tests, creating test factories, or following TDD red-green-refactor cycle.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Jest testing patterns, factory functions, mocking strategies, and TDD workflow. Use when writing unit tests, creating test factories, or following TDD red-green-refactor cycle.
type
skill
created
2026-02-27T00:00:00.000Z
domain
software-development
category
testing
risk
unknown
source
community
tags
["skill","software-development","testing"]
Testing Patterns and Utilities
Testing Philosophy
Test-Driven Development (TDD):
Write failing test FIRST
Implement minimal code to pass
Refactor after green
Never write production code without a failing test
Behavior-Driven Testing:
Test behavior, not implementation
Focus on public APIs and business requirements
Avoid testing implementation details
Use descriptive test names that describe behavior
Factory Pattern:
Create getMockX(overrides?: Partial<X>) functions
Provide sensible defaults
Allow overriding specific properties
Keep tests DRY and maintainable
Test Utilities
Custom Render Function
Create a custom render that wraps components with required providers:
// Element must existexpect(screen.getByText('Hello')).toBeTruthy();
// Element should not existexpect(screen.queryByText('Goodbye')).toBeNull();
// Element appears asynchronouslyawaitwaitFor(() => {
expect(screen.findByText('Loaded')).toBeTruthy();
});