integ-tests/typescript/README.md
This directory contains integration tests for the BAML TypeScript client. These tests verify the functionality of the TypeScript client library and ensure it works correctly with various BAML features.
cd engine/language_client_typescript
pnpm build:debug
pnpm install
pnpm generate
pnpm integ-tests
You can run specific tests by using the -t flag followed by the test name pattern:
pnpm integ-tests -t "works with fallbacks"
infisical (default)pnpm integ-tests
pnpm integ-tests:dotenv
For CI environments, use:
pnpm integ-tests:ci
After running tests, a HTML test report is generated as test-report.html in the project root. This report includes:
tests/ - Test filesbaml_client/ - Generated BAML client codesrc/ - Source files for test utilities and helpersjest.config.js - Jest test configurationtsconfig.json - TypeScript configurationInstall the Jest Runner extension for VS Code
Create a launch configuration in .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Tests",
"runtimeExecutable": "infisical",
"runtimeArgs": ["run", "--env=test", "--"],
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--testTimeout", "30000"],
"console": "integratedTerminal",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
console.log() statements in your testsBAML_LOG=trace to see detailed BAML client logs:BAML_LOG=trace pnpm integ-tests
Missing API Keys
.env file exists if using integ-tests:dotenvinteg-testsBuild Issues
pnpm build:debug
pnpm generate
node_modules and rebuild if needed:
rm -rf node_modules
pnpm install
Test Timeouts
pnpm integ-tests -- --testTimeout 60000
BAML Client Generation Issues
../baml_src are validrm -rf baml_client
pnpm generate
Jest Configuration Issues
*.test.ts patterntests/ directoryjest.config.js is correcttest-report.html for detailed error information--verbose=true for more detailed test output:
pnpm integ-tests -- --verbose=true
First, add your test definitions in the BAML source files (see BAML Source README):
baml_src/clients.bamlbaml_src/test-files/providers/pnpm generate
This will create new TypeScript client code in baml_client/.
Create a new test file in tests/ directory:
import { TestAnthropicCompletion } from "../baml_client/functions";
describe("Anthropic Tests", () => {
it("should complete basic prompt", async () => {
const result = await TestAnthropicCompletion({
input: "What is the capital of France?",
});
expect(result).toBe("Paris");
});
it("should handle errors", async () => {
await expect(
TestAnthropicCompletion({
input: "Test input",
}),
).rejects.toThrow();
});
});
# Run all tests
pnpm integ-tests
# Run specific test file
pnpm integ-tests -t "Anthropic Tests"
.test.ts extensiontests/ directoryTest Setup
baml_client/describe and it blocksAssertions
Environment