Skip to main content

TestConductor

Complete test harness with mocking capabilities.

create()

Create a test conductor instance.
Options:
Example:

Methods

executeEnsemble()

Execute ensemble in test mode.
Returns:
Example:

mock()

Mock an agent or operation.
Example:

spy()

Spy on agent/operation execution.
Example:

clearMocks()

Clear all mocks.

reset()

Reset test conductor state.

Custom Matchers

Vitest matchers for Conductor testing.

Setup

Matchers

toBeSuccessful()

Assert execution succeeded.

toHaveFailed()

Assert execution failed.

toHaveOutput()

Assert specific output.

toHaveExecutedAgent()

Assert agent was executed.

toHaveExecutedOperation()

Assert operation was executed.

toHaveDuration()

Assert execution duration.

toMatchState()

Assert final state.

Mock Implementations

MockAIProvider

Mock AI provider for testing.

MockDatabase

Mock D1 database.

MockKV

Mock KV namespace.

MockVectorize

Mock Vectorize index.

Testing Patterns

Unit Testing

Test individual agents.

Integration Testing

Test complete ensembles.

Mocking External Services

Testing State

Testing Errors

Best Practices

1. Use Descriptive Test Names
2. Test Happy Path and Error Cases
3. Mock External Dependencies
4. Assert on Multiple Aspects
5. Use Spies for Call Verification

Next Steps

Core Classes

Core API

Testing Guide

Testing patterns

Examples

Example tests

Vitest

Vitest docs