@jaypie/testkit
Test utilities and mocks for Jaypie applications.
Overview
Section titled âOverviewâ@jaypie/testkit provides comprehensive testing utilities, including:
- Mocks for all Jaypie services
- Custom Vitest matchers
- Test helpers and utilities
- Mock creation utilities
Installation
Section titled âInstallationânpm install --save-dev @jaypie/testkitKey Features
Section titled âKey FeaturesâService Mocks
Section titled âService MocksâComplete mocking system for all Jaypie services:
import { mock } from "@jaypie/testkit";
// Mock LLMmock.Llm.operate();
// Mock Express handlerconst app = mock.expressHandler(handler);
// Mock Datadog metricsmock.submitMetric();Custom Matchers
Section titled âCustom MatchersâVitest matchers for Jaypie-specific assertions:
import { toThrowJaypieError } from "@jaypie/testkit";
expect.extend({ toThrowJaypieError });
expect(() => { throw new BadRequestError("Invalid input");}).toThrowJaypieError(BadRequestError);Mock Utilities
Section titled âMock UtilitiesâCreate custom mocks with fallback behavior:
import { createMockWrappedFunction } from "@jaypie/testkit";
const mockFn = createMockWrappedFunction(originalFn, { fallback: "default value",});Logger Mocks
Section titled âLogger MocksâMock logger for testing logging behavior:
import { mockLogFactory, spyLog, restoreLog } from "@jaypie/testkit";
const mockLog = mockLogFactory();spyLog(log);// ... test code ...restoreLog(log);API Documentation
Section titled âAPI DocumentationâAPI documentation will be generated from TypeScript definitions.
Related Packages
Section titled âRelated Packagesâ- @jaypie/core - Core utilities
- @jaypie/express - Express.js integration
- @jaypie/llm - LLM utilities