MCPcopy
hub / github.com/vitest-dev/vitest / Vitest

Class Vitest

packages/vitest/src/node/core.ts:67–1668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67export class Vitest {
68 /**
69 * Current Vitest version.
70 * @example '2.0.0'
71 */
72 public readonly version: string = version
73 static readonly version: string = version
74 /**
75 * The logger instance used to log messages. It's recommended to use this logger instead of `console`.
76 * It's possible to override stdout and stderr streams when initiating Vitest.
77 * @example
78 * new Vitest('test', {
79 * stdout: new Writable(),
80 * })
81 */
82 public readonly logger: Logger
83 /**
84 * The package installer instance used to install Vitest packages.
85 * @example
86 * await vitest.packageInstaller.ensureInstalled('@vitest/browser', process.cwd())
87 */
88 public readonly packageInstaller: VitestPackageInstaller
89 /**
90 * A path to the built Vitest directory. This is usually a folder in `node_modules`.
91 */
92 public readonly distPath: string = distDir
93 /**
94 * A list of projects that are currently running.
95 * If projects were filtered with `--project` flag, they won't appear here.
96 */
97 public projects: TestProject[] = []
98 /**
99 * A watcher handler. This is not the file system watcher. The handler only
100 * exposes methods to handle changed files.
101 *
102 * If you have your own watcher, you can use these methods to replicate
103 * Vitest behaviour.
104 */
105 public readonly watcher: VitestWatcher
106 /**
107 * The version control system provider used to detect changed files.
108 * This is used with the `--changed` flag to determine which test files to run.
109 * By default, Vitest uses Git. You can provide a custom implementation via
110 * `experimental.vcsProvider` in your config.
111 */
112 public vcs!: VCSProvider
113
114 /** @internal */ configOverride: Partial<ResolvedConfig> = {}
115 /** @internal */ filenamePattern?: string[]
116 /** @internal */ runningPromise?: Promise<TestRunResult>
117 /** @internal */ closingPromise?: Promise<void>
118 /** @internal */ cancelPromise?: Promise<void | void[]>
119 /** @internal */ isCancelling = false
120 /** @internal */ coreWorkspaceProject: TestProject | undefined
121 /** @internal */ _browserSessions = new BrowserSessions()
122 /** @internal */ _cliOptions: CliOptions = {}
123 /** @internal */ reporters: Reporter[] = []
124 /** @internal */ runner!: ModuleRunner

Callers

nothing calls this directly

Calls 4

getRootProjectMethod · 0.95
resolveProjectsFunction · 0.90
nanoidFunction · 0.85
joinFunction · 0.50

Tested by

no test coverage detected