← All procedures

vitest.coverage

Run vitest once with coverage, and check a minimum line coverage (no shell)

MCPCLI
Package
@procedures/vitest · README
Path
["vitest","coverage"]
CLI
mark vitest coverage
MCP tool
vitest.coverage on the dev-tools server
As data
{"$proc":["vitest","coverage"],"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","coverage"], {});
console.log(JSON.stringify(result));

From the command line

$ mark vitest coverage

As data, in a program

{ "$proc": ["vitest", "coverage"], "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
thresholdnumbernoThe minimum line coverage in percent. Below it, the result has `success: false`.

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"
        }
      },
      "threshold": {
        "description": "The minimum line coverage in percent. Below it, the result has `success: false`.",
        "type": "number"
      }
    }
  },
  "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": {}
  }
}