Skip to content

SandboxMocker

Defined in: sandbox.ts:120

Sandbox execution mocking utilities class.

Provides methods for mocking Docker container execution during testing.

import { SandboxMocker } from 'vitest-agentic-control';
const mocker = new SandboxMocker();
// Mock successful execution
mocker.mockExecution({
success: true,
stdout: 'Hello from container!',
exitCode: 0,
});
// Create a mock container
const container = mocker.createMockContainer({
image: 'node:22',
workdir: '/app',
});
// Execute command in mock container
const result = await container.exec(['npm', 'test']);
expect(result.success).toBe(true);

new SandboxMocker(options?): SandboxMocker

Defined in: sandbox.ts:139

SandboxMockerOptions = {}

SandboxMocker

readonly containers: Map<string, MockContainer>

Defined in: sandbox.ts:128

Track mock containers

createMockContainer(config?): MockContainer

Defined in: sandbox.ts:197

Create a mock container.

MockContainerConfig = {}

Container configuration

MockContainer

Mock container instance


createMockRuntime(name, command?): object

Defined in: sandbox.ts:423

Create a mock runtime adapter.

string

Runtime name

string[] = ...

Command to return from prepareCommand

object

name: string

parseOutput: Mock<(output) => unknown>

prepareCommand: Mock<(prompt, options?) => string[]>


getContainer(id): MockContainer | undefined

Defined in: sandbox.ts:448

Get a container by ID.

string

MockContainer | undefined


getContainerIds(): string[]

Defined in: sandbox.ts:441

Get all container IDs.

string[]


mockContainerManager(): Mock

Defined in: sandbox.ts:356

Mock the ContainerManager class from agentic-control.

Mock


mockDockerCommands(): void

Defined in: sandbox.ts:255

Mock Docker CLI commands.

void


mockExecution(result): void

Defined in: sandbox.ts:162

Set the default execution result.

MockExecutionResult

The result to return from executions

void


mockSandboxExecutor(): Mock

Defined in: sandbox.ts:399

Mock the SandboxExecutor class from agentic-control.

Mock


queueResult(result): void

Defined in: sandbox.ts:171

Queue a result to be returned from the next execution.

MockExecutionResult

The result to queue

void


queueResults(results): void

Defined in: sandbox.ts:180

Queue multiple results to be returned from executions.

MockExecutionResult[]

The results to queue

void


resetAll(): void

Defined in: sandbox.ts:464

Reset all mocks.

void


restoreAll(): void

Defined in: sandbox.ts:455

Restore all mocked modules.

void