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

Function testErrorFormat

apps/sim/tools/index.test.ts:1256–1283  ·  view source on GitHub ↗
(name: string, errorResponse: any, expectedError: string)

Source from the content-addressed store, hash-verified

1254 })
1255
1256 const testErrorFormat = async (name: string, errorResponse: any, expectedError: string) => {
1257 global.fetch = Object.assign(
1258 vi.fn().mockImplementation(async () => ({
1259 ok: false,
1260 status: 400,
1261 statusText: 'Bad Request',
1262 headers: {
1263 get: (key: string) => (key === 'content-type' ? 'application/json' : null),
1264 forEach: (callback: (value: string, key: string) => void) => {
1265 callback('application/json', 'content-type')
1266 },
1267 },
1268 text: () => Promise.resolve(JSON.stringify(errorResponse)),
1269 json: () => Promise.resolve(errorResponse),
1270 clone: vi.fn().mockReturnThis(),
1271 })),
1272 { preconnect: vi.fn() }
1273 ) as typeof fetch
1274
1275 const result = await executeTool(
1276 'function_execute',
1277 { code: 'return { result: "test" }' },
1278 { skipPostProcess: true }
1279 )
1280
1281 expect(result.success).toBe(false)
1282 expect(result.error).toBe(expectedError)
1283 }
1284
1285 it('should extract GraphQL error format (Linear API)', async () => {
1286 await testErrorFormat(

Callers 1

index.test.tsFile · 0.85

Calls 2

executeToolFunction · 0.90
resolveMethod · 0.65

Tested by

no test coverage detected