80eede9a6f83 docs: Guide for Continue CLI for a Documentation writing agent (#7988) Erica Hughberg,
| .. | ||
| __tests__/ | ||
| README.md | 2.5 KiB | |
| adapter-mocks.ts | 2.7 KiB | |
| cli-helpers.ts | 6.4 KiB | |
| mock-helpers.ts | 4.3 KiB | |
| mock-llm-server.ts | 8.3 KiB | |
| renderWithServices.tsx | 1.2 KiB | |
| testServiceContainer.ts | 3.5 KiB | |
| ui-test-context-minimal.ts | 1.3 KiB | |
| ui-test-context.ts | 3.2 KiB | |
README.md
Test Helpers
This directory contains helper functions for testing the Continue CLI.
Mock LLM Server
The mock-llm-server.ts module provides utilities for creating mock LLM servers in tests. This allows you to test the CLI's behavior without making real API calls.
Basic Usage
import {
setupMockLLMTest,
cleanupMockLLMServer,
} from "../test-helpers/mock-llm-server.js";
describe("My Test", () => {
let context: any;
let mockServer: MockLLMServer;
beforeEach(async () => {
context = await createTestContext();
mockServer = await setupMockLLMTest(context, {
response: "Hello from mock LLM!",
});
});
afterEach(async () => {
await cleanupMockLLMServer(mockServer);
await cleanupTestContext(context);
});
it("should get response from mock", async () => {
const result = await runCLI(context, {
args: ["-p", "Test prompt", "--config", context.configPath],
});
expect(result.stdout).toContain("Hello from mock LLM!");
});
});
Advanced Usage
Dynamic Responses
mockServer = await setupMockLLMTest(context, {
response: (prompt: string) => {
if (prompt.includes("weather")) {
return "It's sunny!";
}
return "Default response";
},
});
Non-Streaming Responses
mockServer = await setupMockLLMTest(context, {
response: "Non-streaming response",
streaming: false, // Sends entire response at once instead of word-by-word
});
Note: The CLI always expects SSE format, so responses are always sent as streaming events. The streaming option only controls whether the response is chunked word-by-word or sent all at once.
Custom Request Handling
const mockServer = await createMockLLMServer({
customHandler: (req, res) => {
// Custom logic here
res.writeHead(200);
res.end("Custom response");
},
});
Request Tracking
The mock server tracks all requests it receives:
// After making requests...
expect(mockServer.requests).toHaveLength(1);
expect(mockServer.requests[0].body.messages[0].content).toBe("User prompt");
API Reference
setupMockLLMTest(context, options)
Sets up a complete test environment with mock LLM server, config file, and skips onboarding.
createMockLLMServer(options)
Creates just the mock server without test environment setup.
createMockLLMConfig(mockServer, modelName)
Generates a config YAML string for the mock server.
cleanupMockLLMServer(mockServer)
Properly shuts down the mock server.