Skip to main content
Glama
mock-factory.template.ts1.15 kB
import { vi } from 'vitest'; /** * Mock factory for creating test data and mock objects */ // TODO: Define interfaces for your mock data interface MockDataInterface { id: string; name: string; // Add other properties } /** * Factory function to create mock data */ export function createMockData(overrides: Partial<MockDataInterface> = {}): MockDataInterface { return { id: 'test-id-123', name: 'Test Name', ...overrides, }; } /** * Factory function to create multiple mock data items */ export function createMockDataArray(count: number, overrides: Partial<MockDataInterface> = {}): MockDataInterface[] { return Array.from({ length: count }, (_, index) => createMockData({ id: `test-id-${index}`, name: `Test Name ${index}`, ...overrides, }) ); } /** * Mock API client functions */ export const mockApiClient = { get: vi.fn(), post: vi.fn(), put: vi.fn(), delete: vi.fn(), // Add other API methods as needed }; /** * Reset all mocks - call this in beforeEach */ export function resetAllMocks(): void { Object.values(mockApiClient).forEach(mock => mock.mockReset()); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server