integ-tests/README.md
This directory contains integration tests for all BAML client libraries. These tests verify that BAML's functionality works correctly across different programming languages.
graph TD
subgraph "Source Files"
A[BAML Source Files] --> |Generate| B[Test Definitions]
B1[clients.baml] --> B
B2[generators.baml] --> B
B3[test-files/*] --> B
end
subgraph "Code Generation"
B --> C[BAML CLI]
C --> D1[TypeScript Client]
C --> D2[Python Client]
C --> D3[Ruby Client]
end
subgraph "Test Execution"
D1 --> E1[TypeScript Tests]
D2 --> E2[Python Tests]
D3 --> E3[Ruby Tests]
E1 --> F[Test Runner]
E2 --> F
E3 --> F
F --> G{Results}
G --> |Success| H1[Report Success]
G --> |Failure| H2[Debug Output]
end
subgraph "Environment"
I[Infisical Secrets] --> E1
I --> E2
I --> E3
J[API Keys] --> I
K[Test Config] --> F
end
style C fill:#f9f,stroke:#333,stroke-width:2px
style F fill:#bbf,stroke:#333,stroke-width:2px
style I fill:#bfb,stroke:#333,stroke-width:2px
The integration tests verify:
Each language directory (typescript/, python/, ruby/) contains similar tests to ensure consistent behavior across all supported languages.
integ-tests/
├── baml_src/ # BAML source files and test definitions
│ ├── clients.baml # Main client definitions
│ ├── generators.baml # Reusable test patterns
│ └── test-files/ # Organized test cases
├── typescript/ # TypeScript integration tests
├── python/ # Python integration tests
├── ruby/ # Ruby integration tests
├── openapi/ # OpenAPI integration tests
└── run-tests.sh # Script to run all tests
First, clone the repository and navigate to the integration tests:
git clone https://github.com/boundaryml/baml.git
cd baml/integ-tests
You'll need the following tools installed:
# Install Rust (required for building native clients)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Node.js and pnpm (for TypeScript tests)
brew install node
npm install -g pnpm
# Install Python 3.8+ and uv (for Python tests)
brew install [email protected]
brew install uv
# Install mise for Ruby (for Ruby tests)
brew install mise
We use Infisical (a secrets management tool) to handle test credentials. You have two options:
a. Using Infisical (Recommended for team members)
brew install infisical
infisical login
b. Using .env File (Recommended for open source contributors)
.env file in the integ-tests directoryOPENAI_API_KEY=your_test_key_here
ANTHROPIC_API_KEY=your_test_key_here
# Add other required keys as needed
Choose one of these methods:
a. Using Infisical (Recommended)
bash infisical run --env=test -- [test command]
b. Using .env Files
- Create a .env file in the root directory
- Run tests without Infisical
Choose your language:
a. TypeScript
bash # Build the debug version of the client cd typescript && pnpm run build:debug
<Note>
For local development, use `pnpm run build:debug` which is much faster. The full `pnpm run build` can take several minutes as it creates an optimized production build.
</Note>
```bash
# Generate the test code
pnpm run generate
# Run tests with Infisical (recommended)
pnpm run integ-tests
# Or run tests with .env file
pnpm run integ-tests:dotenv
```
b. Python ```bash cd python
# Install dependencies
uv sync
# Build the client library
uv run maturin develop --manifest-path ../../engine/language_client_python/Cargo.toml
# Generate the test code
uv run baml-cli generate --from ../baml_src
# Run tests with Infisical (recommended)
infisical run --env=test -- uv run pytest
# Or run tests with .env file
uv run pytest
```
c. Ruby ```bash cd ruby
# Install dependencies
bundle install
# Build and generate code
rake generate
# Run tests with Infisical (recommended)
infisical run --env=test -- rake test
# Or run tests with .env file
rake test
```
baml update-client
./run-tests.shEach language has its own debugging setup in VSCode:
See individual language READMEs for detailed debugging instructions.
To test the BAML VSCode extension playground:
root-wasm32.code-workspace file in VSCodeImportant: Make sure to open the workspace file as it contains necessary VSCode settings and extensions for development.
For more detailed instructions on running the playground, see the TypeScript README.
Client Generation Failures
baml_src/Build Issues
Environment Variables
Test Timeouts
BAML_LOG=tracebaml_src/The baml_client folder in each language contains all necessary files for deployment. You don't need the BAML compiler in production environments.