MCPcopy Index your code
hub / github.com/simstudioai/sim / createToolMockFetch

Function createToolMockFetch

packages/testing/src/builders/tool-tester.builder.ts:64–82  ·  view source on GitHub ↗
(
  responseData: unknown,
  options: { ok?: boolean; status?: number; headers?: Record<string, string> } = {}
)

Source from the content-addressed store, hash-verified

62 * Wraps the @sim/testing createMockFetch with tool-specific additions.
63 */
64export function createToolMockFetch(
65 responseData: unknown,
66 options: { ok?: boolean; status?: number; headers?: Record<string, string> } = {}
67) {
68 const { ok = true, status = 200, headers = { 'Content-Type': 'application/json' } } = options
69
70 const mockFetchConfig: MockFetchResponse = {
71 json: responseData,
72 status,
73 ok,
74 headers,
75 text: typeof responseData === 'string' ? responseData : JSON.stringify(responseData),
76 }
77
78 const baseMockFetch = createBaseMockFetch(mockFetchConfig)
79 ;(baseMockFetch as MockFetch).preconnect = vi.fn()
80
81 return baseMockFetch as MockFetch
82}
83
84/**
85 * Creates a mock error fetch function.

Callers 2

constructorMethod · 0.85
setupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected