Testing Expert Skill
Expert in testing strategies for React, Next.js, and NestJS applications.
When to Use This Skill
- Writing unit tests
- Creating integration tests
- Setting up E2E tests
- Testing React components
- Testing API endpoints
- Testing database operations
- Setting up test infrastructure
- Reviewing test coverage
Project Context Discovery
- Scan Documentation: Check
.agents/memory/ for durable project context (architecture, deployment, gotchas)
- Identify Tools: Jest/Vitest, React Testing Library, Supertest, Playwright/Cypress
- Discover Patterns: Review existing test files, utilities, mocking patterns
- Use Project-Specific Skills: Check for
[project]-testing-expert skill
Core Testing Principles
Testing Pyramid
- Unit Tests (70%): Fast, isolated, test individual functions/components
- Integration Tests (20%): Test component interactions
- E2E Tests (10%): Test full user flows
Coverage Targets
- Line coverage: > 80%
- Branch coverage: > 75%
- Function coverage: > 85%
- Critical paths: 100%
Test Organization
src/
users/
users.controller.ts
users.controller.spec.ts # Unit tests
users.service.ts
users.service.spec.ts
__tests__/
integration/
e2e/
Test Quality (AAA Pattern)
it('should return users filtered by organization', async () => {
// Arrange: Set up test data
const organizationId = 'org1';
const expectedUsers = [{ organization: organizationId }];
// Act: Execute the code being tested
const result = await service.findAll(organizationId);
// Assert: Verify the result
expect(result).toEqual(expectedUsers);
});
Good Tests Are
- Independent (no test dependencies)
- Fast (< 100ms each)
- Repeatable (same result every time)
- Meaningful (test real behavior)
- Maintainable (easy to update)
Testing Best Practices Summary
- Test Isolation: Each test independent, clean up after
- Meaningful Tests: Test behavior, not implementation
- Mocking Strategy: Mock external dependencies, not what you're testing
- Test Data: Use factories, keep data minimal, clean up
- Coverage: High coverage, focus on critical paths
Integration
| Test Type |
Tools |
Use Case |
| Unit |
Jest/Vitest |
Functions, components, services |
| Integration |
Supertest + Jest |
Controller + Service + DB |
| E2E |
Playwright/Cypress |
Full user flows |
| Component |
React Testing Library |
React component behavior |
For complete React Testing Library examples, hook testing, Next.js page/API testing, NestJS service/controller testing, integration test setup, E2E test patterns, MongoDB testing, authentication helpers, test fixtures, and mocking patterns, see: references/full-guide.md
1---2name: testing-expert-23description: Expert in testing strategies for React, Next.js, and NestJS applications covering unit tests, integration tests, E2E tests, and testing best practices4---56# Testing Expert Skill78Expert in testing strategies for React, Next.js, and NestJS applications.910## When to Use This Skill1112- Writing unit tests13- Creating integration tests14- Setting up E2E tests15- Testing React components16- Testing API endpoints17- Testing database operations18- Setting up test infrastructure19- Reviewing test coverage2021## Project Context Discovery22231. **Scan Documentation:** Check `.agents/memory/` for durable project context (architecture, deployment, gotchas)242. **Identify Tools:** Jest/Vitest, React Testing Library, Supertest, Playwright/Cypress253. **Discover Patterns:** Review existing test files, utilities, mocking patterns264. **Use Project-Specific Skills:** Check for `[project]-testing-expert` skill2728## Core Testing Principles2930### Testing Pyramid3132- **Unit Tests** (70%): Fast, isolated, test individual functions/components33- **Integration Tests** (20%): Test component interactions34- **E2E Tests** (10%): Test full user flows3536### Coverage Targets3738- Line coverage: > 80%39- Branch coverage: > 75%40- Function coverage: > 85%41- Critical paths: 100%4243### Test Organization4445```46src/47 users/48 users.controller.ts49 users.controller.spec.ts # Unit tests50 users.service.ts51 users.service.spec.ts52 __tests__/53 integration/54 e2e/55```5657### Test Quality (AAA Pattern)5859```typescript60it('should return users filtered by organization', async () => {61 // Arrange: Set up test data62 const organizationId = 'org1';63 const expectedUsers = [{ organization: organizationId }];6465 // Act: Execute the code being tested66 const result = await service.findAll(organizationId);6768 // Assert: Verify the result69 expect(result).toEqual(expectedUsers);70});71```7273## Good Tests Are7475- Independent (no test dependencies)76- Fast (< 100ms each)77- Repeatable (same result every time)78- Meaningful (test real behavior)79- Maintainable (easy to update)8081## Testing Best Practices Summary82831. **Test Isolation:** Each test independent, clean up after842. **Meaningful Tests:** Test behavior, not implementation853. **Mocking Strategy:** Mock external dependencies, not what you're testing864. **Test Data:** Use factories, keep data minimal, clean up875. **Coverage:** High coverage, focus on critical paths8889## Integration9091| Test Type | Tools | Use Case |92|-----------|-------|----------|93| Unit | Jest/Vitest | Functions, components, services |94| Integration | Supertest + Jest | Controller + Service + DB |95| E2E | Playwright/Cypress | Full user flows |96| Component | React Testing Library | React component behavior |9798---99100**For complete React Testing Library examples, hook testing, Next.js page/API testing, NestJS service/controller testing, integration test setup, E2E test patterns, MongoDB testing, authentication helpers, test fixtures, and mocking patterns, see:** `references/full-guide.md`