Overview
aixyz provides aloadEnv utility from aixyz/test for loading environment variables during tests. Combined with Bun’s built-in test runner, you can write both deterministic and non-deterministic agent tests.
Test File Convention
Place your test file alongside your agent:Writing Tests
loadEnv()
The loadEnv function from aixyz/test loads environment variables for test runs. It loads .env.test.local (where your OPENAI_API_KEY lives for tests) while .env.local is ignored during testing.
Deterministic vs Non-Deterministic
| Type | Description | CI-Safe |
|---|---|---|
| Deterministic | Validate agent type, tools, config | Yes |
| Non-deterministic | Call LLM and validate response content | No* |
test.skipIf(!process.env.OPENAI_API_KEY) to skip gracefully when no API key is available.