Overview

What is MockMaster?

MockMaster is a powerful, type-safe API mocking library that revolutionizes how you test your applications. Instead of writing brittle mock data by hand, MockMaster lets you capture real API responses and replay them deterministically in your tests. Built for modern TypeScript applications with full type inference and strict typing.


Use Cases

MockMaster excels in several scenarios:

  • Integration Testing - Deterministic API responses for reliable tests
  • Offline Development - Work without network access
  • CI/CD Pipelines - Fast tests that don’t hit real APIs
  • Storybook Development - Develop UI components with realistic data
  • Contract Testing - Validate against OpenAPI specs
  • Demo Environments - Present apps without backend dependencies

Quick Example

import { parseYaml } from '@mockmaster/openapi'
import { generateScenariosFromSpec } from '@mockmaster/cli'
import { createReplayHandler } from '@mockmaster/msw-adapter'
 
// Parse OpenAPI spec
const spec = parseYaml(`
openapi: 3.0.0
info:
  title: User API
  version: 1.0.0
paths:
  /users:
    get:
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id: { type: integer }
                    name: { type: string }
                    email: { type: string, format: email }
`)
 
// Generate scenarios with realistic data
const scenarios = generateScenariosFromSpec(spec, 'user-api')
 
// Replay in tests
const handler = createReplayHandler(scenarios[0])
const response = handler({ method: 'GET', path: '/users' })
 
console.log(response.body)
// [
//   { id: 1, name: 'John Doe', email: 'john@example.com' },
//   { id: 2, name: 'Jane Smith', email: 'jane@example.com' }
// ]

Getting Started

Ready to get started? Check out the Installation guide and follow our Quick Start tutorial to build your first scenario in 5 minutes.

Learn More


Community & Support