import { n as normalize } from './chunk-utils-env.b861e3a0.js'; import cac from 'cac'; import c from 'picocolors'; import { v as version, s as startVitest, d as divider } from './chunk-snapshot-manager.700322bf.js'; import 'node:url'; import 'path'; import './chunk-integrations-coverage.44413252.js'; import 'local-pkg'; import './chunk-env-node.b3664da2.js'; import 'node:console'; import './chunk-mock-date.a1c85759.js'; import 'node:path'; import 'vite'; import 'node:process'; import 'node:fs'; import 'os'; import 'util'; import 'stream'; import 'events'; import 'fs'; import './vendor-_commonjsHelpers.addc3445.js'; import 'vite-node/client'; import 'vite-node/server'; import 'node:fs/promises'; import './vendor-index.b2fdde54.js'; import 'node:buffer'; import 'node:child_process'; import './vendor-index.7a2cebfe.js'; import 'child_process'; import 'assert'; import 'buffer'; import 'node:os'; import 'source-map'; import 'module'; import 'acorn'; import 'acorn-walk'; import 'node:worker_threads'; import 'tinypool'; import './vendor-index.783e7f3e.js'; import 'perf_hooks'; import './chunk-utils-source-map.60562959.js'; import './chunk-utils-timers.52534f96.js'; import 'crypto'; import 'vite-node/utils'; import './vendor-index.9c919048.js'; import 'node:crypto'; import './chunk-magic-string.3a794426.js'; import 'strip-literal'; import 'readline'; import './vendor-index.9f20a9be.js'; const cli = cac("vitest"); cli.version(version).option("-r, --root ", "root path").option("-c, --config ", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern ", "run tests with full names matching the specified pattern").option("--dir ", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port , --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter ", "reporter").option("--outputDiffMaxSize ", "object diff output max size (default: 10000)").option("--outputDiffMaxLines ", "max lines in diff output window (default: 50)").option("--outputTruncateLength ", "diff output line length (default: 80)").option("--outputDiffLines ", "number of lines in single diff (default: 15)").option("--outputFile ", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "enable coverage report").option("--run", "do not watch").option("--mode ", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment ", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--logHeapUsage", "show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard ", "Test suite shard to execute in a format of /").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence ", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--no-color", "Removes colors from the console output").option("--segfault-retry ", "Return tests on segment fault (default: 0)", { default: 0 }).option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").help(); cli.command("run [...filters]").action(run); cli.command("related [...filters]").action(runRelated); cli.command("watch [...filters]").action(watch); cli.command("dev [...filters]").action(watch); cli.command("bench [...filters]").action(benchmark); cli.command("typecheck [...filters]").action(typecheck); cli.command("[...filters]").action((filters, options) => start("test", filters, options)); cli.parse(); async function runRelated(relatedFiles, argv) { argv.related = relatedFiles; argv.passWithNoTests ?? (argv.passWithNoTests = true); await start("test", [], argv); } async function watch(cliFilters, options) { options.watch = true; await start("test", cliFilters, options); } async function run(cliFilters, options) { options.run = true; await start("test", cliFilters, options); } async function benchmark(cliFilters, options) { console.warn(c.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it.")); await start("benchmark", cliFilters, options); } async function typecheck(cliFilters = [], options = {}) { console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it.")); await start("typecheck", cliFilters, options); } function normalizeCliOptions(argv) { if (argv.root) argv.root = normalize(argv.root); else delete argv.root; if (argv.config) argv.config = normalize(argv.config); else delete argv.config; if (argv.dir) argv.dir = normalize(argv.dir); else delete argv.dir; return argv; } async function start(mode, cliFilters, options) { try { const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options)); if (!(ctx == null ? void 0 : ctx.config.watch)) await (ctx == null ? void 0 : ctx.exit()); return ctx; } catch (e) { console.error(` ${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`); console.error(e); console.error("\n\n"); process.exit(1); } }