Testing Guides
MockMaster integrates seamlessly with popular testing frameworks.
Supported Frameworks
Vitest
Fast, modern unit and integration testing for Vite projects.
Features:
- Native ESM support
- Fast execution
- Compatible API with Jest
- Built-in TypeScript support
npm install -D vitestJest
Popular JavaScript testing framework with comprehensive features.
Features:
- Snapshot testing
- Mocking utilities
- Code coverage
- Large ecosystem
npm install -D jestPlaywright
End-to-end testing for modern web applications.
Features:
- Cross-browser testing
- Auto-wait for elements
- Network interception
- Visual regression testing
npm install -D @playwright/testCommon Patterns
Load Scenario in Tests
import { readScenario } from '@mockmaster/cli'
import { createReplayHandler } from '@mockmaster/msw-adapter'
const scenario = await readScenario('./scenarios', 'user-api')
const handler = createReplayHandler(scenario)
const response = handler({ method: 'GET', path: '/users' })Setup in beforeEach
describe('API Tests', () => {
let handler: ReturnType<typeof createReplayHandler>
beforeEach(async () => {
const scenario = await readScenario('./scenarios', 'user-api')
handler = createReplayHandler(scenario)
})
it('fetches users', () => {
const response = handler({ method: 'GET', path: '/users' })
expect(response.status).toBe(200)
})
})Framework-Specific Guides
- Vitest Guide - Complete Vitest integration
- Jest Guide - Complete Jest integration
- Playwright Guide - E2E testing with Playwright
Next Steps
Choose your testing framework and follow the detailed guide:
- Vitest - For modern Vite-based projects
- Jest - For traditional JavaScript projects
- Playwright - For end-to-end testing