Skip to content

Commit

Permalink
fix: mock response handler to prevent API calls
Browse files Browse the repository at this point in the history
Co-Authored-By: Han Xiao <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and hanxiao committed Feb 13, 2025
1 parent 0c002be commit 56c55d1
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/tools/__tests__/evaluator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,6 @@ jest.mock('@ai-sdk/google', () => ({
GoogleChatLanguageModel: jest.fn()
}));

// Mock provider utils to prevent API calls
jest.mock('@ai-sdk/provider-utils', () => ({
postToApi: jest.fn().mockResolvedValue({
data: {
choices: [{
message: {
function_call: {
arguments: JSON.stringify(mockEvalResponse)
}
}
}]
}
})
}));

// Mock OpenAI API
jest.mock('@ai-sdk/openai', () => ({
OpenAIChatLanguageModel: jest.fn().mockImplementation(() => ({
Expand All @@ -91,6 +76,14 @@ jest.mock('@ai-sdk/openai', () => ({
}))
}));

// Mock response handler to prevent API calls
jest.mock('@ai-sdk/provider-utils/src/response-handler', () => ({
handleResponse: jest.fn().mockImplementation(() => ({
object: mockEvalResponse,
usage: { totalTokens: 0 }
}))
}));

jest.mock('../../utils/token-tracker');

// Mock readUrl to prevent actual API calls
Expand Down

0 comments on commit 56c55d1

Please sign in to comment.