Skip to content

Testing Integration

CodeBuddy can run your project’s tests, parse the results, and fix failing tests — all through natural language. It auto-detects your test framework and knows how to filter, run, and interpret results for 6 frameworks.

PriorityFrameworkDetected viaCommand
1Vitestpackage.json scripts/devDepsnpx vitest run
2Jestpackage.json scripts/devDepsnpx jest
3Mochapackage.json scripts/devDepsnpx mocha / npm test --
4Pytestpytest.ini, pyproject.toml, setup.pypython -m pytest
5Go testgo.modgo test ./...
6Cargo testCargo.tomlcargo test
fallbacknpm testpackage.json with non-default test scriptnpm test --

Detection runs in priority order — the first match wins. You can also override detection entirely with a custom command.

Each framework supports running a specific test by name:

FrameworkFlag
Jest--testNamePattern
Vitest-t
Mocha--grep
Pytest-k
Go-run
Cargo-- (pass-through)

In Agent mode, CodeBuddy uses the run_tests tool to execute tests:

run_tests({ testPath?: "src/auth/", testName?: "should validate token" })

The tool:

  1. Detects the framework (or uses your custom command)
  2. Spawns the test process with shell: false for security
  3. Parses the output into structured results
  4. Formats a markdown summary for the agent
{
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"
}
]
}

The agent receives a formatted summary with pass/fail counts, up to 10 failure details, and the last 2,000 characters of raw output.

The tester subagent specializes in test-driven workflows:

  1. Analyze — read the code under test
  2. Identify — determine what test cases are needed
  3. Write — create or update test files
  4. Run — execute tests via run_tests
  5. Fix — if tests fail, fix the code and re-run

This subagent is invoked automatically during collaboration playbooks:

WorkflowSubagent chain
New featureArchitect → Reviewer → Developer → Tester → Reviewer
Bug fixDebugger → Developer → Tester
RefactorCode Analyzer → Architect → File Organizer → Developer → Tester

The tester has access to: run_tests, edit_file, manage_terminal, ripgrep_search, get_diagnostics, list_files, search_vector_db, git, browser, and MCP tools.

Test execution uses strict security measures:

  • shell: false — arguments are passed as an array, preventing shell injection
  • Argument sanitization — all arguments are validated against shell metacharacters (;|&$(){}!<>) with a 500-character limit
  • Environment — forced to FORCE_COLOR=0, CI=true for clean, parseable output
  • Custom command parsing — respects single/double quotes properly
SettingTypeDefaultDescription
codebuddy.testCommandstring""Custom test command. Overrides auto-detection entirely
codebuddy.testTimeoutnumber120000Test execution timeout in ms (5,000–600,000)
  • “Run the tests for the auth module”
  • “Run only the test named ‘should validate token’”
  • “Write tests for src/utils/parser.ts and run them”
  • “Fix the failing tests and make sure they all pass”
  • “Add unit tests for all exported functions in this file”