Skip to main content

Overview

test_run auto-detects the test framework from your project configuration and runs tests with structured output. Instead of raw terminal output, it returns parsed results: pass/fail/skip counts, failure details with file:line locations, and optionally coverage data. Supported frameworks: vitest, jest, pytest, go test, cargo test, mocha, jasmine, and more.

Tool: test_run

Security level: moderate | Tier: Standard
command
string
Override the auto-detected test command. Leave blank to use auto-detection.
file
string
Run tests only in a specific file.
grep
string
Filter by test name pattern. Passes --grep to vitest/jest or -k to pytest.
coverage
boolean
default:"false"
Enable code coverage reporting.

Examples

{}

Response Format

{
  "success": true,
  "data": {
    "framework": "vitest",
    "passed": 42,
    "failed": 2,
    "skipped": 3,
    "total": 47,
    "durationMs": 3241,
    "failures": [
      {
        "name": "queue > retries exhausted > should emit failed event",
        "file": "src/queue/task-queue.test.ts",
        "line": 88,
        "message": "Expected 'failed' to equal 'error'"
      }
    ],
    "coverage": null
  }
}

Framework Auto-Detection

The tool checks for the following config files in order:
Config FileFramework
vitest.config.ts / vitest.config.jsvitest
jest.config.ts / jest.config.jsjest
pytest.ini / pyproject.tomlpytest
go.modgo test
Cargo.tomlcargo test
package.json with "jest" keyjest
package.json with "vitest" keyvitest

Timeouts

Tests are limited to 2 minutes (120,000ms) by default. Long-running integration test suites should use the command override to set a higher timeout:
{
  "command": "pnpm vitest run --testTimeout=300000"
}

Output Truncation

Raw test output is capped at 200,000 characters. For very large test suites, use the file or grep parameters to narrow down which tests to run.

File Operations

Read test files to understand what they test before running.

Code Analysis

Lint and type-check in addition to running tests.