interface ResolvedConfig {
    alias: AliasOptions;
    allowOnly: boolean;
    api?: ApiConfig;
    bail: number;
    base?: string;
    benchmark?: Required<Omit<BenchmarkUserOptions, "outputFile">> & Pick<BenchmarkUserOptions, "outputFile">;
    browser: ResolvedBrowserOptions;
    cache: false | {
        dir: string;
    };
    chaiConfig: ChaiConfig;
    changed: string | boolean;
    clearMocks: boolean;
    cliExclude?: string[];
    config?: string;
    coverage: ResolvedCoverageOptions<Provider>;
    css: boolean | {
        exclude?: RegExp | RegExp[];
        include?: RegExp | RegExp[];
        modules?: {
            classNameStrategy?: CSSModuleScopeStrategy;
        };
    };
    dangerouslyIgnoreUnhandledErrors: boolean;
    defines: Record<string, any>;
    deps: DepsOptions;
    diff: string;
    dir: string;
    dom: boolean;
    env: Record<string, string>;
    environment: VitestEnvironment;
    environmentMatchGlobs: [string, VitestEnvironment][];
    environmentOptions: EnvironmentOptions;
    exclude: string[];
    expandSnapshotDiff: boolean;
    fakeTimers: FakeTimerInstallOpts;
    fileParallelism: boolean;
    filters?: string[];
    forceRerunTriggers: string[];
    globalSetup: string | string[];
    globals: boolean;
    hideSkippedTests: boolean;
    hookTimeout: number;
    include: string[];
    includeSource: string[];
    inspect: boolean;
    inspectBrk: boolean;
    isolate: boolean;
    logHeapUsage: boolean;
    maxConcurrency: number;
    maxWorkers: number;
    minWorkers: number;
    mockReset: boolean;
    mode: VitestRunMode;
    name: string;
    onConsoleLog: ((log, type) => false | void);
    onStackTrace: ((error, frame) => boolean | void);
    open: boolean;
    outputFile: string | Partial<Record<"default" | "json" | "verbose" | "basic" | "dot" | "tap" | "tap-flat" | "junit" | "hanging-process", string>> & Record<string, string>;
    passWithNoTests: boolean;
    pool: Pool;
    poolMatchGlobs: [string, "typescript" | "threads" | "forks" | "vmThreads" | string & {}][];
    poolOptions?: PoolOptions;
    project: string | string[];
    related?: string[];
    reporters: ("default" | "json" | "verbose" | "basic" | "dot" | "tap" | "tap-flat" | "junit" | "hanging-process" | Reporter)[];
    restoreMocks: boolean;
    retry: number;
    root: string;
    runner?: string;
    sequence: {
        concurrent?: boolean;
        hooks: SequenceHooks;
        seed: number;
        sequencer: TestSequencerConstructor;
        setupFiles: SequenceSetupFiles;
        shuffle?: boolean;
    };
    server: Omit<ViteNodeServerOptions, "transformMode">;
    setupFiles: string | string[];
    shard?: {
        count: number;
        index: number;
    };
    silent: boolean;
    slowTestThreshold: number;
    snapshotFormat: Omit<PrettyFormatOptions, "plugins">;
    snapshotOptions: SnapshotStateOptions;
    teardownTimeout: number;
    testNamePattern?: RegExp;
    testTimeout: number;
    testTransformMode: TransformModePatterns;
    typecheck: Omit<TypecheckConfig, "enabled"> & {
        enabled: boolean;
    };
    ui: boolean;
    uiBase: string;
    unstubEnvs: boolean;
    unstubGlobals: boolean;
    update: boolean;
    watch: boolean;
    watchExclude: string[];
    workspace: string;
}

Hierarchy

  • Omit<Required<UserConfig>, "config" | "filters" | "browser" | "coverage" | "testNamePattern" | "related" | "api" | "reporters" | "resolveSnapshotPath" | "benchmark" | "shard" | "cache" | "sequence" | "typecheck" | "runner" | "poolOptions" | "pool" | "cliExclude">
    • ResolvedConfig

Properties

alias: AliasOptions

Specifies an Object, or an Array of Object, which defines aliases used to replace values in import or require statements. Will be merged with the default aliases inside resolve.alias.

allowOnly: boolean

Allow tests and suites that are marked as only

api?: ApiConfig
bail: number

Stop test execution when given number of tests have failed.

base?: string
benchmark?: Required<Omit<BenchmarkUserOptions, "outputFile">> & Pick<BenchmarkUserOptions, "outputFile">
browser: ResolvedBrowserOptions
cache: false | {
    dir: string;
}

Type declaration

  • dir: string
chaiConfig: ChaiConfig

Modify default Chai config. Vitest uses Chai for expect and assert matches. https://github.com/chaijs/chai/blob/4.x.x/lib/chai/config.js

changed: string | boolean

Runs tests that are affected by the changes in the repository, or between specified branch or commit hash Requires initialized git repository

Default

false
clearMocks: boolean

Will call .mockClear() on all spies before each test

Default

false
cliExclude?: string[]
config?: string
coverage: ResolvedCoverageOptions<Provider>
css: boolean | {
    exclude?: RegExp | RegExp[];
    include?: RegExp | RegExp[];
    modules?: {
        classNameStrategy?: CSSModuleScopeStrategy;
    };
}

Indicates if CSS files should be processed.

When excluded, the CSS files will be replaced with empty strings to bypass the subsequent processing.

Type declaration

Default

{ include: [], modules: { classNameStrategy: false } }
dangerouslyIgnoreUnhandledErrors: boolean

Ignore any unhandled errors that occur

defines: Record<string, any>
deps: DepsOptions

Handling for dependencies inlining or externalizing

diff: string

Path to a module which has a default export of diff config.

dir: string

Base directory to scan for the test files

Default

config.root

dom: boolean

Use happy-dom

env: Record<string, string>

Custom environment variables assigned to process.env before running tests.

environment: VitestEnvironment

Running environment

Supports 'node', 'jsdom', 'happy-dom', 'edge-runtime'

If used unsupported string, will try to load the package vitest-environment-${env}

Default

'node'
environmentMatchGlobs: [string, VitestEnvironment][]

Automatically assign environment based on globs. The first match will be used. This has effect only when running tests inside Node.js.

Format: [glob, environment-name]

Default

[]

Example

[
// all tests in tests/dom will run in jsdom
['tests/dom/**', 'jsdom'],
// all tests in tests/ with .edge.test.ts will run in edge-runtime
['**/*.edge.test.ts', 'edge-runtime'],
// ...
]
environmentOptions: EnvironmentOptions

Environment options.

exclude: string[]

Exclude globs for test files

Default

['node_modules', 'dist', '.idea', '.git', '.cache']
expandSnapshotDiff: boolean

Show full diff when snapshot fails instead of a patch.

fakeTimers: FakeTimerInstallOpts

Options for @sinon/fake-timers

fileParallelism: boolean

Should all test files run in parallel. Doesn't affect tests running in the same file. Setting this to false will override maxWorkers and minWorkers options to 1.

Default

true
filters?: string[]
forceRerunTriggers: string[]

Glob patter of file paths that will trigger the whole suite rerun

Useful if you are testing calling CLI commands

Default

[]
globalSetup: string | string[]

Path to global setup files

globals: boolean

Register apis globally

Default

false
hideSkippedTests: boolean

Hide logs for skipped tests

Default

false
hookTimeout: number

Default timeout of a hook in milliseconds

Default

10000
include: string[]

Include globs for test files

Default

['**/*.{test,spec}.?(c|m)[jt]s?(x)']
includeSource: string[]

Include globs for in-source test files

Default

[]
inspect: boolean

Debug tests by opening node:inspector in worker / child process. Provides similar experience as --inspect Node CLI argument.

Requires poolOptions.threads.singleThread: true OR poolOptions.forks.singleFork: true.

inspectBrk: boolean

Debug tests by opening node:inspector in worker / child process and wait for debugger to connect. Provides similar experience as --inspect-brk Node CLI argument.

Requires poolOptions.threads.singleThread: true OR poolOptions.forks.singleFork: true.

isolate: boolean

Run tests in an isolated environment. This option has no effect on vmThreads pool.

Disabling this option might improve performance if your code doesn't rely on side effects.

Default

true
logHeapUsage: boolean

Show heap usage after each test. Useful for debugging memory leaks.

maxConcurrency: number

A number of tests that are allowed to run at the same time marked with test.concurrent.

Default

5
maxWorkers: number

Maximum number of workers to run tests in. poolOptions.{threads,vmThreads}.maxThreads/poolOptions.forks.maxForks has higher priority.

minWorkers: number

Minimum number of workers to run tests in. poolOptions.{threads,vmThreads}.minThreads/poolOptions.forks.minForks has higher priority.

mockReset: boolean

Will call .mockReset() on all spies before each test

Default

false
name: string

Name of the project. Will be used to display in the reporter.

onConsoleLog: ((log, type) => false | void)

Custom handler for console.log in tests.

Return false to ignore the log.

Type declaration

    • (log, type): false | void
    • Custom handler for console.log in tests.

      Return false to ignore the log.

      Parameters

      • log: string
      • type: "stdout" | "stderr"

      Returns false | void

onStackTrace: ((error, frame) => boolean | void)

Enable stack trace filtering. If absent, all stack trace frames will be shown.

Return false to omit the frame.

Type declaration

    • (error, frame): boolean | void
    • Enable stack trace filtering. If absent, all stack trace frames will be shown.

      Return false to omit the frame.

      Parameters

      Returns boolean | void

open: boolean

Open UI automatically.

Default

true
outputFile: string | Partial<Record<"default" | "json" | "verbose" | "basic" | "dot" | "tap" | "tap-flat" | "junit" | "hanging-process", string>> & Record<string, string>

Write test results to a file when the --reporter=jsonor--reporter=junit` option is also specified. Also definable individually per reporter by using an object instead.

passWithNoTests: boolean

Pass with no tests

pool: Pool
poolMatchGlobs: [string, "typescript" | "threads" | "forks" | "vmThreads" | string & {}][]

Automatically assign pool based on globs. The first match will be used.

Format: [glob, pool-name]

Default

[]

Example

[
// all tests in "forks" directory will run using "poolOptions.forks" API
['tests/forks/**', 'forks'],
// all other tests will run based on "poolOptions.threads" option, if you didn't specify other globs
// ...
]
poolOptions?: PoolOptions
project: string | string[]

Name of the project or projects to run.

related?: string[]
reporters: ("default" | "json" | "verbose" | "basic" | "dot" | "tap" | "tap-flat" | "junit" | "hanging-process" | Reporter)[]
restoreMocks: boolean

Will call .mockRestore() on all spies before each test

Default

false
retry: number

Retry the test specific number of times if it fails.

Default

0
root: string

Project root

Default

process.cwd()
runner?: string
sequence: {
    concurrent?: boolean;
    hooks: SequenceHooks;
    seed: number;
    sequencer: TestSequencerConstructor;
    setupFiles: SequenceSetupFiles;
    shuffle?: boolean;
}

Type declaration

server: Omit<ViteNodeServerOptions, "transformMode">

Vite-node server options

setupFiles: string | string[]

Path to setup files

shard?: {
    count: number;
    index: number;
}

Type declaration

  • count: number
  • index: number
silent: boolean

Silent mode

Default

false
slowTestThreshold: number

The number of milliseconds after which a test is considered slow and reported as such in the results.

Default

300
snapshotFormat: Omit<PrettyFormatOptions, "plugins">

Format options for snapshot testing.

snapshotOptions: SnapshotStateOptions
teardownTimeout: number

Default timeout to wait for close when Vitest shuts down, in milliseconds

Default

10000
testNamePattern?: RegExp
testTimeout: number

Default timeout of a test in milliseconds

Default

5000
testTransformMode: TransformModePatterns

Determine the transform method for all modules imported inside a test that matches the glob pattern.

typecheck: Omit<TypecheckConfig, "enabled"> & {
    enabled: boolean;
}

Type declaration

  • enabled: boolean
ui: boolean

Enable Vitest UI

uiBase: string

Base url for the UI

Default

'/__vitest__/'
unstubEnvs: boolean

Will restore all env stubs to their original values before each test

Default

false
unstubGlobals: boolean

Will restore all global stubs to their original values before each test

Default

false
update: boolean

Update snapshot

Default

false
watch: boolean

Watch mode

Default

true
watchExclude: string[]

Glob pattern of file paths to be ignore from triggering watch rerun

workspace: string

Path to a workspace configuration file

Generated using TypeDoc