← All procedures

vitest.run

Run vitest tests once (no shell; uses the project's own vitest)

MCPCLI
Package
@procedures/vitest · README
Path
["vitest","run"]
CLI
mark vitest run
MCP tool
vitest.run on the dev-tools server
As data
{"$proc":["vitest","run"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/vitest"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["vitest","run"], {});
console.log(JSON.stringify(result));

From the command line

$ mark vitest run

As data, in a program

{ "$proc": ["vitest", "run"], "input": {} }

Input

FieldTypeRequiredDefaultDescription
cwdstringnoThe folder of the project (default: the current folder)
includestring[]noTest files or patterns to run (default: all tests)
excludestring[]noTest files or patterns to leave out
watchbooleannoRun in watch mode (use vitest.watch for a long-running watcher)
coveragebooleannoMeasure the coverage and give the percentages
reporter"default" | "verbose" | "json" | "junit"noThe vitest reporter
passWithNoTestsbooleannoSucceed when no test file matches

Output

FieldTypeRequiredDefaultDescription
successbooleanyesTrue when vitest ended with exit code 0 (and, for vitest.coverage, the threshold is met)
passednumberyesThe number of tests that passed
failednumberyesThe number of tests that failed
skippednumberyesThe number of tests that were skipped
durationnumberyesThe time of the run, in milliseconds
exitCodenumberyesThe exit code of vitest (-1 when a signal ended it)
stdoutstringyesThe last 64 KiB of the output
stderrstringyesThe last 64 KiB of the error output
coverageobjectnoThe coverage percentages, when the run measured coverage
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "cwd": {
        "description": "The folder of the project (default: the current folder)",
        "type": "string"
      },
      "include": {
        "description": "Test files or patterns to run (default: all tests)",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "exclude": {
        "description": "Test files or patterns to leave out",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "watch": {
        "description": "Run in watch mode (use vitest.watch for a long-running watcher)",
        "type": "boolean"
      },
      "coverage": {
        "description": "Measure the coverage and give the percentages",
        "type": "boolean"
      },
      "reporter": {
        "description": "The vitest reporter",
        "type": "string",
        "enum": [
          "default",
          "verbose",
          "json",
          "junit"
        ]
      },
      "passWithNoTests": {
        "description": "Succeed when no test file matches",
        "type": "boolean"
      }
    }
  },
  "output": {
    "type": "object",
    "properties": {
      "success": {
        "type": "boolean",
        "description": "True when vitest ended with exit code 0 (and, for vitest.coverage, the threshold is met)"
      },
      "passed": {
        "type": "number",
        "description": "The number of tests that passed"
      },
      "failed": {
        "type": "number",
        "description": "The number of tests that failed"
      },
      "skipped": {
        "type": "number",
        "description": "The number of tests that were skipped"
      },
      "duration": {
        "type": "number",
        "description": "The time of the run, in milliseconds"
      },
      "exitCode": {
        "type": "number",
        "description": "The exit code of vitest (-1 when a signal ended it)"
      },
      "stdout": {
        "type": "string",
        "description": "The last 64 KiB of the output"
      },
      "stderr": {
        "type": "string",
        "description": "The last 64 KiB of the error output"
      },
      "coverage": {
        "description": "The coverage percentages, when the run measured coverage",
        "type": "object",
        "properties": {
          "lines": {
            "type": "number",
            "description": "The line coverage, in percent"
          },
          "branches": {
            "type": "number",
            "description": "The branch coverage, in percent"
          },
          "functions": {
            "type": "number",
            "description": "The function coverage, in percent"
          },
          "statements": {
            "type": "number",
            "description": "The statement coverage, in percent"
          }
        },
        "required": [
          "lines",
          "branches",
          "functions",
          "statements"
        ],
        "additionalProperties": {}
      }
    },
    "required": [
      "success",
      "passed",
      "failed",
      "skipped",
      "duration",
      "exitCode",
      "stdout",
      "stderr"
    ],
    "additionalProperties": {}
  }
}