diff options
| author | Tommaso Sciortino <[email protected]> | 2025-08-12 15:57:27 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-12 22:57:27 +0000 |
| commit | 9d023be1d16a6bf7427569f863e6cfd2c3442d8b (patch) | |
| tree | b983227f56fd9f26008b475061a345b61207c970 /integration-tests/google_web_search.test.ts | |
| parent | 8d6eb8c322890b5cdf20d4a30dd17afb1541f5aa (diff) | |
Upgrade integration tests to use Vitest (#6021)
Diffstat (limited to 'integration-tests/google_web_search.test.ts')
| -rw-r--r-- | integration-tests/google_web_search.test.ts | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/integration-tests/google_web_search.test.ts b/integration-tests/google_web_search.test.ts index 6fb365a0..698edfe5 100644 --- a/integration-tests/google_web_search.test.ts +++ b/integration-tests/google_web_search.test.ts @@ -4,74 +4,78 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { test } from 'node:test'; -import { strict as assert } from 'assert'; +import { describe, it, expect } from 'vitest'; import { TestRig, printDebugInfo, validateModelOutput } from './test-helper.js'; -test('should be able to search the web', async () => { - const rig = new TestRig(); - await rig.setup('should be able to search the web'); +describe('google_web_search', () => { + it('should be able to search the web', async () => { + const rig = new TestRig(); + await rig.setup('should be able to search the web'); - let result; - try { - result = await rig.run(`what is the weather in London`); - } catch (error) { - // Network errors can occur in CI environments - if ( - error instanceof Error && - (error.message.includes('network') || error.message.includes('timeout')) - ) { - console.warn( - 'Skipping test due to network error:', - (error as Error).message, - ); - return; // Skip the test + let result; + try { + result = await rig.run(`what is the weather in London`); + } catch (error) { + // Network errors can occur in CI environments + if ( + error instanceof Error && + (error.message.includes('network') || error.message.includes('timeout')) + ) { + console.warn( + 'Skipping test due to network error:', + (error as Error).message, + ); + return; // Skip the test + } + throw error; // Re-throw if not a network error } - throw error; // Re-throw if not a network error - } - const foundToolCall = await rig.waitForToolCall('google_web_search'); + const foundToolCall = await rig.waitForToolCall('google_web_search'); - // Add debugging information - if (!foundToolCall) { - const allTools = printDebugInfo(rig, result); + // Add debugging information + if (!foundToolCall) { + const allTools = printDebugInfo(rig, result); - // Check if the tool call failed due to network issues - const failedSearchCalls = allTools.filter( - (t) => - t.toolRequest.name === 'google_web_search' && !t.toolRequest.success, - ); - if (failedSearchCalls.length > 0) { - console.warn( - 'google_web_search tool was called but failed, possibly due to network issues', - ); - console.warn( - 'Failed calls:', - failedSearchCalls.map((t) => t.toolRequest.args), + // Check if the tool call failed due to network issues + const failedSearchCalls = allTools.filter( + (t) => + t.toolRequest.name === 'google_web_search' && !t.toolRequest.success, ); - return; // Skip the test if network issues + if (failedSearchCalls.length > 0) { + console.warn( + 'google_web_search tool was called but failed, possibly due to network issues', + ); + console.warn( + 'Failed calls:', + failedSearchCalls.map((t) => t.toolRequest.args), + ); + return; // Skip the test if network issues + } } - } - assert.ok(foundToolCall, 'Expected to find a call to google_web_search'); + expect( + foundToolCall, + 'Expected to find a call to google_web_search', + ).toBeTruthy(); - // Validate model output - will throw if no output, warn if missing expected content - const hasExpectedContent = validateModelOutput( - result, - ['weather', 'london'], - 'Google web search test', - ); + // Validate model output - will throw if no output, warn if missing expected content + const hasExpectedContent = validateModelOutput( + result, + ['weather', 'london'], + 'Google web search test', + ); - // If content was missing, log the search queries used - if (!hasExpectedContent) { - const searchCalls = rig - .readToolLogs() - .filter((t) => t.toolRequest.name === 'google_web_search'); - if (searchCalls.length > 0) { - console.warn( - 'Search queries used:', - searchCalls.map((t) => t.toolRequest.args), - ); + // If content was missing, log the search queries used + if (!hasExpectedContent) { + const searchCalls = rig + .readToolLogs() + .filter((t) => t.toolRequest.name === 'google_web_search'); + if (searchCalls.length > 0) { + console.warn( + 'Search queries used:', + searchCalls.map((t) => t.toolRequest.args), + ); + } } - } + }); }); |
