This document covers the test environment configuration and mocking infrastructure used in the signals repository. The testing setup provides mechanisms to override production services, disable persistence layers, and configure in-memory adapters for the agent-swarm-kit framework.
For information about the overall build process, see Build Process. For Docker-based testing environments, see Docker Configuration.
The testing infrastructure is designed around two key configuration files that establish a controlled testing environment by:
The test setup follows a two-stage initialization process where overrides are applied before the main system initializes, ensuring that test-specific configurations take precedence over production settings.
Stage | Purpose | File | Key Actions |
---|---|---|---|
Override | Service Mocking | override.ts |
License service override |
Setup | Environment Config | setup.ts |
Agent framework configuration |
Import | Module Loading | setup.ts |
Main signals module import |
Adaptation | Storage Mocking | setup.ts |
Persistence adapter setup |
The testing framework uses the di-kit
library's beforeInit
mechanism to override specific services before the dependency injection container initializes them.
The licenseService
is overridden to always return true
from its validate()
method, bypassing any license validation requirements during testing:
override(Symbol.for("licenseService"), {
async validate() {
return true;
}
})
The setup.ts
file configures the agent-swarm-kit framework for testing by disabling various persistence and storage mechanisms that would interfere with test execution.
Setting | Production Value | Test Value | Purpose |
---|---|---|---|
CC_PERSIST_ENABLED_BY_DEFAULT |
true |
false |
Disable automatic persistence |
CC_PERSIST_MEMORY_STORAGE |
true |
false |
Disable memory storage persistence |
CC_PERSIST_EMBEDDING_CACHE |
true |
false |
Disable embedding cache persistence |
CC_STORAGE_DISABLE_GET_DATA |
false |
true |
Disable data retrieval operations |
The test configuration provides mock implementations for the persistence layer to prevent actual data storage during test execution.
The PersistEmbedding
adapter is replaced with a mock that:
false
for hasValue()
checksreadValue()
is calledwriteValue()
callsPersistEmbedding.usePersistEmbeddingAdapter(
class extends PersistBase {
async waitForInit() {}
async readValue(): Promise<any> {
throw new Error("Unimplemented method");
}
async hasValue() {
return false;
}
async writeValue() {}
}
);
The History
service uses the HistoryMemoryInstance
adapter, which provides in-memory storage for conversation history without persistence to external storage systems.
The testing setup ensures complete isolation from production systems by:
This isolation guarantees that tests run in a controlled environment without affecting production data or requiring external service dependencies.