UNPKG

@dbs-portal/tool-mock

Version:

API mocking toolkit using MSW for DBS Portal development workflows

61 lines 1.81 kB
/** * Jest matchers for MSW testing - extends Jest's expect functionality */ import type { RequestHandler } from 'msw'; /** * Custom Jest matchers for MSW * These extend Jest's built-in expect functionality with MSW-specific assertions */ export declare const mswMatchers: { /** * Assert that a mock handler was called * Usage: expect(mockHandler).toHaveBeenCalled() */ toHaveBeenCalled(_received: RequestHandler): { message: () => string; pass: boolean; }; /** * Assert that a mock handler was called with specific parameters * Usage: expect(mockHandler).toHaveBeenCalledWith({ method: 'GET', url: '/api/users' }) */ toHaveBeenCalledWith(_received: RequestHandler, expected: { method?: string; url?: string; body?: any; }): { message: () => string; pass: boolean; }; /** * Assert that a mock handler was called a specific number of times * Usage: expect(mockHandler).toHaveBeenCalledTimes(3) */ toHaveBeenCalledTimes(_received: RequestHandler, expected: number): { message: () => string; pass: boolean; }; }; /** * Setup Jest matchers for MSW * Call this in your Jest setup file to extend expect with MSW-specific matchers */ export declare function setupMSWMatchers(): void; /** * Type declarations for Jest matchers * Add this to your Jest setup or types file */ declare global { namespace jest { interface Matchers<R> { toHaveBeenCalled(): R; toHaveBeenCalledWith(expected: { method?: string; url?: string; body?: any; }): R; toHaveBeenCalledTimes(expected: number): R; } } } //# sourceMappingURL=assertions.d.ts.map