Skip to main content

Overview

The runTests method executes tests in the sandbox environment and automatically detects the appropriate test runner (e.g., npm test, pytest, cargo test, etc.). This method supports both streaming and non-streaming execution modes.

Method Signature

Parameters

string
The Git branch to run tests on. If not specified, tests will run on the current branch.
Conversation[]
Optional conversation history to provide context for the test execution. This can help the agent understand previous interactions and make more informed decisions about test execution.
VibeKitStreamCallbacks
Optional callbacks for streaming updates during test execution.

Return Value

Returns a Promise<AgentResponse> containing the test execution results:
string
The ID of the sandbox where tests were executed
string
Standard output from the test execution
string
Standard error output from the test execution
number
Exit code from the test execution (0 indicates success)

Examples

Basic Test Execution

Run Tests on Specific Branch

Streaming Test Execution

Run Tests with Context

Test Runner Detection

The runTests method automatically detects and uses the appropriate test runner based on the project structure:
  • Node.js: Runs npm test or yarn test
  • Python: Runs pytest, python -m unittest, or python -m pytest
  • Rust: Runs cargo test
  • Go: Runs go test
  • And more: Supports various other testing frameworks

Error Handling

Notes

  • The method requires an active sandbox environment
  • Test execution is performed within the sandbox, ensuring a clean and isolated environment
  • The agent will attempt to install dependencies if they’re missing
  • Streaming callbacks provide real-time feedback during test execution
  • The method works with both Codex and Claude agents