Testing Integration
Detects your test framework, runs tests, parses results, and fixes failing tests via natural-language requests.
Supported frameworks
Section titled “Supported frameworks”Detection runs in priority order — first match wins. Or override entirely with codebuddy.testCommand.
| Priority | Framework | Detected via | Command |
|---|---|---|---|
| 1 | Vitest | package.json scripts / devDeps | npx vitest run |
| 2 | Jest | package.json scripts / devDeps | npx jest |
| 3 | Mocha | package.json scripts / devDeps | npx mocha / npm test -- |
| 4 | Pytest | pytest.ini, pyproject.toml, setup.py | python -m pytest |
| 5 | Go test | go.mod | go test ./... |
| 6 | Cargo test | Cargo.toml | cargo test |
| fallback | npm test | package.json with a non-default test script | npm test -- |
Test-name filtering per framework:
| Framework | Flag |
|---|---|
| Jest | --testNamePattern |
| Vitest | -t |
| Mocha | --grep |
| Pytest | -k |
| Go | -run |
| Cargo | -- (pass-through) |
The run_tests tool
Section titled “The run_tests tool”run_tests({ testPath?: "src/auth/", testName?: "should validate token" })- Detects framework (or uses your custom command).
- Spawns test process with
shell: false. - Parses output into structured results.
- Returns a markdown summary to the agent.
Result shape:
{ framework: "jest", command: "npx jest src/auth/", passed: 42, failed: 3, skipped: 1, total: 46, duration: "4.2s", success: false, failures: [ { testName: "should validate expired token", file: "src/auth/token.test.ts", message: "Expected: false, Received: true", expected: "false", actual: "true" } ]}Agent receives a formatted summary with pass/fail counts, up to 10 failure details, and the last 2000 chars of raw output.
Test-fix loops (tester subagent)
Section titled “Test-fix loops (tester subagent)”Test-driven workflow specialist:
- Analyze — read code under test.
- Identify — determine needed test cases.
- Write — create/update test files.
- Run — via
run_tests. - Fix — patch failing code and re-run.
Invoked automatically in collaboration playbooks:
| Workflow | Chain |
|---|---|
| New feature | Architect → Reviewer → Developer → Tester → Reviewer |
| Bug fix | Debugger → Developer → Tester |
| Refactor | Code Analyzer → Architect → File Organizer → Developer → Tester |
Tester has access to run_tests, edit_file, manage_terminal, ripgrep_search, get_diagnostics, list_files, search_vector_db, git, browser, plus MCP tools.
Security
Section titled “Security”shell: false— args passed as array, no shell injection.- Arg sanitization — validated against shell metacharacters (
;|&$(){}!<>), 500-char limit each. - Env — forced to
FORCE_COLOR=0,CI=truefor clean parseable output. - Custom command parsing — respects single + double quotes properly.
Settings
Section titled “Settings”| Setting | Default | Purpose |
|---|---|---|
codebuddy.testCommand | "" | Custom test command — overrides auto-detection |
codebuddy.testTimeout | 120000 | Execution timeout (ms, 5000–600 000) |
Example prompts
Section titled “Example prompts”- “Run the tests for the auth module”
- “Run only the test named ‘should validate token’”
- “Write tests for
src/utils/parser.tsand run them” - “Fix the failing tests and make sure they all pass”
- “Add unit tests for all exported functions in this file”
Related
Section titled “Related”- Subagents —
testerrole - Deep terminal — the terminal path tests run through