mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-26 14:01:14 -07:00
1.9 KiB
1.9 KiB
Gemini CLI Test Utils (@google/gemini-cli-test-utils)
Shared test utilities used across the monorepo. This is a private package — not published to npm.
Key Modules
src/test-rig.ts: The primary test rig for spinning up end-to-end CLI sessions with mock responses.src/file-system-test-helpers.ts: Helpers for creating temporary file system fixtures.src/mock-utils.ts: Common mock utilities.src/test-mcp-server.ts: Helper for building test MCP servers for tests.src/test-mcp-server-template.mjs: Generic template script for running isolated MCP processes.
Test MCP Servers
The TestRig provides a fully isolated, compliant way to test tool triggers and
workflows using local test MCP servers. This isolates your tests from live API
endpoints and rate-limiting.
Usage
-
Programmatic Builder:
import { TestMcpServerBuilder } from '@google/gemini-cli-test-utils'; const builder = new TestMcpServerBuilder('weather-server').addTool( 'get_weather', 'Get weather', 'It is rainy', ); rig.addTestMcpServer('weather-server', builder.build()); -
Predefined configurations via JSON: Place a configuration file in
packages/test-utils/assets/test-servers/google-workspace.jsonand load it by title:rig.addTestMcpServer('workspace-server', 'google-workspace');JSON Format Structure (
TestMcpConfig):{ "name": "string (Fallback server name)", "tools": [ { "name": "string (Tool execution name)", "description": "string (Helpful summary for router)", "inputSchema": { "type": "object", "properties": { ... } }, "response": "string | object (The forced reply payload)" } ] }
Usage
Import from @google/gemini-cli-test-utils in test files across the monorepo.