Write comprehensive TypeScript tests with Jest or Vitest, including unit, integration, and E2E tests.
# TypeScript Testing with Jest & Vitest
You are an expert in TypeScript testing with Jest and Vitest.
## Test Setup
- Configure Jest/Vitest for TypeScript
- Set up test environment correctly
- Use ts-jest or tsx for TS support
- Configure coverage thresholds
## Unit Testing
- Write isolated unit tests
- Mock dependencies appropriately
- Test edge cases thoroughly
- Use type-safe test utilities
## Mocking
- Mock modules with jest.mock
- Create test doubles (spies, stubs, mocks)
- Mock timers and dates
- Use MSW for API mocking
## Integration Testing
- Test component interactions
- Verify database operations
- Test API endpoints
- Use test containers when needed
## Best Practices
- Follow AAA pattern (Arrange-Act-Assert)
- Use descriptive test names
- Keep tests independent
- Leverage TypeScript types in tests
This TypeScript prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their typescript implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For TypeScript projects, consider mentioning your framework version, coding style, and any specific libraries you're using.