Skip to content

AgenticMocker

Defined in: mocking.ts:59

Main mocker class for comprehensive agentic-control testing.

This class provides a unified interface for mocking all agentic-control components: MCP servers, AI providers, sandbox execution, and more.

import { AgenticMocker } from 'vitest-agentic-control';
const mocker = new AgenticMocker();
// Mock MCP server
mocker.mcp.mockServer('my-server', {
tools: [{ name: 'tool1', handler: () => 'result' }],
});
// Mock AI provider
mocker.providers.mockAnthropic({ response: 'Hello!' });
// Mock sandbox execution
mocker.sandbox.mockExecution({ success: true, output: 'Done!' });
// Clean up after test
mocker.restoreAll();

new AgenticMocker(options?): AgenticMocker

Defined in: mocking.ts:77

Creates a new AgenticMocker instance.

AgenticMockerOptions = {}

Configuration options for the mocker

AgenticMocker

readonly mcp: McpMocker

Defined in: mocking.ts:61

MCP mocking utilities


readonly providers: ProviderMocker

Defined in: mocking.ts:63

AI provider mocking utilities


readonly sandbox: SandboxMocker

Defined in: mocking.ts:65

Sandbox execution mocking utilities

createSpy<T>(implementation?): Mock<T>

Defined in: mocking.ts:102

Create a spy on a function.

T extends (…args) => unknown

T

Optional implementation for the spy

Mock<T>

The mock function


mockAllFrameworks(): Record<string, unknown>

Defined in: mocking.ts:116

Mock all agentic-control framework modules.

This mocks the common modules used in agentic-control:

  • MCP SDK modules
  • AI SDK modules
  • GitHub client modules

Record<string, unknown>

Dictionary of all mocked modules


mockEnv(env): () => void

Defined in: mocking.ts:167

Mock environment variables temporarily.

Record<string, string>

Environment variables to set

Cleanup function to restore original values

(): void

void


mockGitHubClient(options?): unknown

Defined in: mocking.ts:136

Mock the GitHub client.

Options for the mock

unknown[]

unknown[]

unknown[]

unknown

The mock GitHub client


mockModule<T>(modulePath, mockValue): T

Defined in: mocking.ts:90

Mock a module by path.

T extends Record<string, unknown>

string

The module path to mock

T

The mock value to use

T

The mock value for chaining


resetAll(): void

Defined in: mocking.ts:207

Reset all mocks without restoring.

void


restoreAll(): void

Defined in: mocking.ts:189

Restore all mocked modules to their original values.

void