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.
Example
Section titled “Example”import { AgenticMocker } from 'vitest-agentic-control';
const mocker = new AgenticMocker();
// Mock MCP servermocker.mcp.mockServer('my-server', { tools: [{ name: 'tool1', handler: () => 'result' }],});
// Mock AI providermocker.providers.mockAnthropic({ response: 'Hello!' });
// Mock sandbox executionmocker.sandbox.mockExecution({ success: true, output: 'Done!' });
// Clean up after testmocker.restoreAll();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AgenticMocker(
options?):AgenticMocker
Defined in: mocking.ts:77
Creates a new AgenticMocker instance.
Parameters
Section titled “Parameters”options?
Section titled “options?”AgenticMockerOptions = {}
Configuration options for the mocker
Returns
Section titled “Returns”AgenticMocker
Properties
Section titled “Properties”
readonlymcp:McpMocker
Defined in: mocking.ts:61
MCP mocking utilities
providers
Section titled “providers”
readonlyproviders:ProviderMocker
Defined in: mocking.ts:63
AI provider mocking utilities
sandbox
Section titled “sandbox”
readonlysandbox:SandboxMocker
Defined in: mocking.ts:65
Sandbox execution mocking utilities
Methods
Section titled “Methods”createSpy()
Section titled “createSpy()”createSpy<
T>(implementation?):Mock<T>
Defined in: mocking.ts:102
Create a spy on a function.
Type Parameters
Section titled “Type Parameters”T extends (…args) => unknown
Parameters
Section titled “Parameters”implementation?
Section titled “implementation?”T
Optional implementation for the spy
Returns
Section titled “Returns”Mock<T>
The mock function
mockAllFrameworks()
Section titled “mockAllFrameworks()”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
Returns
Section titled “Returns”Record<string, unknown>
Dictionary of all mocked modules
mockEnv()
Section titled “mockEnv()”mockEnv(
env): () =>void
Defined in: mocking.ts:167
Mock environment variables temporarily.
Parameters
Section titled “Parameters”Record<string, string>
Environment variables to set
Returns
Section titled “Returns”Cleanup function to restore original values
():
void
Returns
Section titled “Returns”void
mockGitHubClient()
Section titled “mockGitHubClient()”mockGitHubClient(
options?):unknown
Defined in: mocking.ts:136
Mock the GitHub client.
Parameters
Section titled “Parameters”options?
Section titled “options?”Options for the mock
issues?
Section titled “issues?”unknown[]
pullRequests?
Section titled “pullRequests?”unknown[]
repositories?
Section titled “repositories?”unknown[]
Returns
Section titled “Returns”unknown
The mock GitHub client
mockModule()
Section titled “mockModule()”mockModule<
T>(modulePath,mockValue):T
Defined in: mocking.ts:90
Mock a module by path.
Type Parameters
Section titled “Type Parameters”T extends Record<string, unknown>
Parameters
Section titled “Parameters”modulePath
Section titled “modulePath”string
The module path to mock
mockValue
Section titled “mockValue”T
The mock value to use
Returns
Section titled “Returns”T
The mock value for chaining
resetAll()
Section titled “resetAll()”resetAll():
void
Defined in: mocking.ts:207
Reset all mocks without restoring.
Returns
Section titled “Returns”void
restoreAll()
Section titled “restoreAll()”restoreAll():
void
Defined in: mocking.ts:189
Restore all mocked modules to their original values.
Returns
Section titled “Returns”void