Testing
ShipKit uses Vitest as its testing framework, with support for unit tests, integration tests, and end-to-end testing.
Overview
The testing system provides:
- Unit testing with Vitest
- Component testing with Testing Library
- End-to-end testing with Playwright
- Coverage reporting
- Mock utilities
- Test helpers
Test Setup
Vitest Configuration
Test Environment Setup
Writing Tests
Unit Tests
Component Tests
API Tests
Test Organization
Directory Structure
Naming Conventions
-
Test Files
- Unit tests:
*.test.ts
- Component tests:
*.test.tsx
- Integration tests:
*.integration.test.ts
- E2E tests:
*.e2e.test.ts
-
Test Suites
- Group by feature/component
- Use descriptive names
- Follow naming pattern
Testing Utilities
Mock Functions
Test Helpers
Running Tests
Test Commands
Coverage Reports
Best Practices
-
Test Organization
- Group related tests
- Use descriptive names
- Follow consistent patterns
- Maintain test isolation
-
Test Quality
- Write focused tests
- Test edge cases
- Avoid test interdependence
- Keep tests maintainable
-
Mocking
- Mock external dependencies
- Use realistic test data
- Clean up after tests
- Document mock behavior
-
Performance
- Run tests in parallel
- Mock heavy operations
- Use test filtering
- Optimize setup/teardown
Common Patterns
Testing Hooks
Testing Forms
Testing API Calls
Notes
- Tests run in JSDOM environment
- Coverage thresholds enforced
- Mocks are automatically reset
- Tests run in parallel
- Watch mode available
- Coverage reports generated