KC's Workspace
    Preparing search index...
    interface InlineConfig {
        alias?: AliasOptions;
        allowOnly?: boolean;
        api?: number | boolean | ApiConfig;
        attachmentsDir?: string;
        bail?: number;
        benchmark?: BenchmarkUserOptions;
        browser?: BrowserConfigOptions;
        cache?: false | { dir: string };
        chaiConfig?: ChaiConfig;
        clearMocks?: boolean;
        coverage?:
            | { provider?: undefined } & CoverageV8Options
            | { provider: "istanbul" } & CoverageIstanbulOptions
            | { provider: "v8" } & CoverageV8Options
            | { provider: "custom" } & CustomProviderOptions;
        css?:
            | boolean
            | {
                exclude?: RegExp
                | RegExp[];
                include?: RegExp | RegExp[];
                modules?: { classNameStrategy?: CSSModuleScopeStrategy };
            };
        dangerouslyIgnoreUnhandledErrors?: boolean;
        deps?: DepsOptions;
        diff?: string
        | SerializedDiffOptions;
        dir?: string;
        disableConsoleIntercept?: boolean;
        env?: Partial<ProcessEnv>;
        environment?: VitestEnvironment;
        environmentOptions?: EnvironmentOptions;
        exclude?: string[];
        execArgv?: string[];
        expandSnapshotDiff?: boolean;
        expect?: {
            poll?: { interval?: number; timeout?: number };
            requireAssertions?: boolean;
        };
        experimental?: {
            fsModuleCache?: boolean;
            fsModuleCachePath?: string;
            openTelemetry?: { enabled: boolean; sdkPath?: string };
            printImportBreakdown?: boolean;
        };
        fakeTimers?: FakeTimerInstallOpts;
        fileParallelism?: boolean;
        forceRerunTriggers?: string[];
        globals?: boolean;
        globalSetup?: string
        | string[];
        hideSkippedTests?: boolean;
        hookTimeout?: number;
        include?: string[];
        includeSource?: string[];
        includeTaskLocation?: boolean;
        inspect?: string | boolean;
        inspectBrk?: string | boolean;
        inspector?: {
            enabled?: boolean;
            host?: string;
            port?: number;
            waitForDebugger?: boolean;
        };
        isolate?: boolean;
        logHeapUsage?: boolean;
        maxConcurrency?: number;
        maxWorkers?: string
        | number;
        mockReset?: boolean;
        name?: string | ProjectName;
        onConsoleLog?: (
            log: string,
            type: "stdout" | "stderr",
            entity: TestModule | TestCase | TestSuite | undefined,
        ) => boolean | void;
        onStackTrace?: (error: TestError, frame: ParsedStack) => boolean | void;
        onUnhandledError?: OnUnhandledErrorCallback;
        open?: boolean;
        outputFile?:
            | string
            | Partial<
                Record<
                    | "default"
                    | "blob"
                    | "verbose"
                    | "dot"
                    | "json"
                    | "tap"
                    | "tap-flat"
                    | "junit"
                    | "tree"
                    | "hanging-process"
                    | "github-actions",
                    string,
                >,
            > & Record<string, string>;
        passWithNoTests?: boolean;
        pool?:
            | string & {}
            | "threads"
            | "forks"
            | "vmThreads"
            | "vmForks"
            | "typescript"
            | PoolRunnerInitializer;
        printConsoleTrace?: boolean;
        projects?: TestProjectConfiguration[];
        provide?: Partial<ProvidedContext>;
        reporters?:
            | Arrayable<(ReporterName | Reporter)>
            | (
                ReporterName | Reporter | [ReporterName] | ["default", Partial<DefaultReporterOptions>] | ["blob", Partial<BlobOptions>] | ["verbose", Partial<DefaultReporterOptions>] | ["dot", Partial<BaseOptions>] | ["json", Partial<JsonOptions>] | ["tap", object] | ["tap-flat", object] | ["junit", Partial<JUnitOptions>] | ["tree", Partial<BaseOptions>] | ["hanging-process", object] | ["github-actions", Partial<GithubActionsReporterOptions>] | ["html", Partial<HTMLOptions>] | [string & {}, Record<string, unknown>]
            )[];
        resolveSnapshotPath?: ResolveSnapshotPathHandler;
        restoreMocks?: boolean;
        retry?: number;
        root?: string;
        runner?: string;
        sequence?: SequenceOptions;
        server?: {
            debug?: { dump?: string
            | true; load?: boolean };
            deps?: ServerDepsOptions;
        };
        setupFiles?: string
        | string[];
        silent?: boolean | "passed-only";
        slowTestThreshold?: number;
        snapshotEnvironment?: string;
        snapshotFormat?: Omit<PrettyFormatOptions, "plugins" | "compareKeys"> & {
            compareKeys?: null;
        };
        snapshotSerializers?: string[];
        teardownTimeout?: number;
        testNamePattern?: string
        | RegExp;
        testTimeout?: number;
        typecheck?: Partial<TypecheckConfig>;
        ui?: boolean;
        uiBase?: string;
        unstubEnvs?: boolean;
        unstubGlobals?: boolean;
        update?: boolean;
        vmMemoryLimit?: string | number;
        watch?: boolean;
        watchTriggerPatterns?: WatcherTriggerPattern[];
    }

    Hierarchy (View Summary)

    Index

    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

    !process.env.CI
    
    api?: number | boolean | ApiConfig

    Serve API options.

    When set to true, the default port is 51204.

    false
    
    attachmentsDir?: string

    Directory path for storing attachments created by context.annotate

    '.vitest-attachments'
    
    bail?: number

    Stop test execution when given number of tests have failed.

    Benchmark options.

    {}
    

    options for test in a browser environment

    false
    
    cache?: false | { dir: string }

    Options for configuring cache policy.

    Type Declaration

    • false
    • { dir: string }
      • dir: string

        Use Vite's "cacheDir" instead if you want to change the cache director. Note caches will be written to "cacheDir/vitest".

    { dir: 'node_modules/.vite/vitest/{project-hash}' }
    
    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

    clearMocks?: boolean

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

    false
    
    coverage?:
        | { provider?: undefined } & CoverageV8Options
        | { provider: "istanbul" } & CoverageIstanbulOptions
        | { provider: "v8" } & CoverageV8Options
        | { provider: "custom" } & CustomProviderOptions

    Coverage options

    Type Declaration

    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.

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

    Ignore any unhandled errors that occur

    false
    

    Handling for dependencies inlining or externalizing

    diff?: string | SerializedDiffOptions

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

    dir?: string

    Base directory to scan for the test files

    config.root

    disableConsoleIntercept?: boolean

    By default, Vitest automatically intercepts console logging during tests for extra formatting of test file, test title, etc... This is also required for console log preview on Vitest UI. However, disabling such interception might help when you want to debug a code with normal synchronous terminal console logging.

    This option has no effect on browser pool since Vitest preserves original logging on browser devtools.

    false
    

    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}

    'node'
    
    environmentOptions?: EnvironmentOptions

    Environment options.

    exclude?: string[]

    Exclude globs for test files

    ['**/node_modules/**', '**/.git/**']
    
    execArgv?: string[]

    Pass additional arguments to node process when spawning the worker.

    See Command-line API | Node.js for more information.

    Set to process.execArgv to pass all arguments of the current process.

    Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103

    [] // no execution arguments are passed
    
    expandSnapshotDiff?: boolean

    Show full diff when snapshot fails instead of a patch.

    expect?: {
        poll?: { interval?: number; timeout?: number };
        requireAssertions?: boolean;
    }

    Configuration options for expect() matches.

    Type Declaration

    • Optionalpoll?: { interval?: number; timeout?: number }

      Default options for expect.poll()

      • Optionalinterval?: number

        Polling interval in milliseconds

        50
        
      • Optionaltimeout?: number

        Timeout in milliseconds

        1000
        
    • OptionalrequireAssertions?: boolean

      Throw an error if tests don't have any expect() assertions.

    experimental?: {
        fsModuleCache?: boolean;
        fsModuleCachePath?: string;
        openTelemetry?: { enabled: boolean; sdkPath?: string };
        printImportBreakdown?: boolean;
    }

    Experimental features

    Type Declaration

    • OptionalfsModuleCache?: boolean

      Enable caching of modules on the file system between reruns.

    • OptionalfsModuleCachePath?: string

      Path relative to the root of the project where the fs module cache will be stored.

      node_modules/.experimental-vitest-cache
      
    • OptionalopenTelemetry?: { enabled: boolean; sdkPath?: string }
    • OptionalprintImportBreakdown?: boolean

      Show imports (top 10) that take a long time.

      Enabling this will also show a breakdown by default in UI, but you can always press a button to toggle it.

    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 option to 1.

    true
    
    forceRerunTriggers?: string[]

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

    Useful if you are testing calling CLI commands

    ['**/package.json/**', '**/{vitest,vite}.config.*/**']
    
    globals?: boolean

    Register apis globally

    false
    
    globalSetup?: string | string[]

    Path to global setup files

    hideSkippedTests?: boolean

    Hide logs for skipped tests

    false
    
    hookTimeout?: number

    Default timeout of a hook in milliseconds

    10000
    
    include?: string[]

    A list of glob patterns that match your test files.

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

    Include globs for in-source test files

    []
    
    includeTaskLocation?: boolean

    Include "location" property inside the test definition

    false
    
    inspect?: string | boolean

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

    Requires fileParallelism: false.

    inspectBrk?: string | 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 fileParallelism: false.

    inspector?: {
        enabled?: boolean;
        host?: string;
        port?: number;
        waitForDebugger?: boolean;
    }

    Inspector options. If --inspect or --inspect-brk is enabled, these options will be passed to the inspector.

    Type Declaration

    • Optionalenabled?: boolean

      Enable inspector

    • Optionalhost?: string

      Host to run inspector on

    • Optionalport?: number

      Port to run inspector on

    • OptionalwaitForDebugger?: boolean

      Wait for debugger to connect before running tests

    isolate?: boolean

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

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

    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.

    5
    
    maxWorkers?: string | number

    Maximum number or percentage of workers to run tests in.

    mockReset?: boolean

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

    false
    
    name?: string | ProjectName

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

    onConsoleLog?: (
        log: string,
        type: "stdout" | "stderr",
        entity: TestModule | TestCase | TestSuite | undefined,
    ) => boolean | void

    Custom handler for console.log in tests.

    Return false to ignore the log.

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

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

    Return false to omit the frame.

    onUnhandledError?: OnUnhandledErrorCallback

    A callback that can return false to ignore an unhandled error

    open?: boolean

    Open UI automatically.

    !process.env.CI
    
    outputFile?:
        | string
        | Partial<
            Record<
                | "default"
                | "blob"
                | "verbose"
                | "dot"
                | "json"
                | "tap"
                | "tap-flat"
                | "junit"
                | "tree"
                | "hanging-process"
                | "github-actions",
                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?:
        | string & {}
        | "threads"
        | "forks"
        | "vmThreads"
        | "vmForks"
        | "typescript"
        | PoolRunnerInitializer

    Pool used to run tests in.

    Supports 'threads', 'forks', 'vmThreads', 'vmForks'

    'forks'
    
    printConsoleTrace?: boolean

    Always print console stack traces.

    false
    

    Options for projects

    Define variables that will be returned from inject in the test environment.

    // vitest.config.ts
    export default defineConfig({
    test: {
    provide: {
    someKey: 'someValue'
    }
    }
    })
    // test file
    import { inject } from 'vitest'
    const value = inject('someKey') // 'someValue'
    reporters?:
        | Arrayable<(ReporterName | Reporter)>
        | (
            ReporterName | Reporter | [ReporterName] | ["default", Partial<DefaultReporterOptions>] | ["blob", Partial<BlobOptions>] | ["verbose", Partial<DefaultReporterOptions>] | ["dot", Partial<BaseOptions>] | ["json", Partial<JsonOptions>] | ["tap", object] | ["tap-flat", object] | ["junit", Partial<JUnitOptions>] | ["tree", Partial<BaseOptions>] | ["hanging-process", object] | ["github-actions", Partial<GithubActionsReporterOptions>] | ["html", Partial<HTMLOptions>] | [string & {}, Record<string, unknown>]
        )[]

    Custom reporter for output. Can contain one or more built-in report names, reporter instances, and/or paths to custom reporters.

    []
    
    resolveSnapshotPath?: ResolveSnapshotPathHandler

    Resolve custom snapshot path

    restoreMocks?: boolean

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

    false
    
    retry?: number

    Retry the test specific number of times if it fails.

    0
    
    root?: string

    Project root

    process.cwd()
    
    runner?: string

    Path to a custom test runner.

    sequence?: SequenceOptions

    Options for configuring the order of running tests.

    server?: {
        debug?: { dump?: string | true; load?: boolean };
        deps?: ServerDepsOptions;
    }
    setupFiles?: string | string[]

    Path to setup files

    silent?: boolean | "passed-only"

    Silent mode

    Use 'passed-only' to see logs from failing tests only.

    false
    
    slowTestThreshold?: number

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

    300
    
    snapshotEnvironment?: string

    Path to a custom snapshot environment module that has a default export of SnapshotEnvironment object.

    snapshotFormat?: Omit<PrettyFormatOptions, "plugins" | "compareKeys"> & {
        compareKeys?: null;
    }

    Format options for snapshot testing.

    snapshotSerializers?: string[]

    Paths to snapshot serializer modules.

    teardownTimeout?: number

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

    10000
    
    testNamePattern?: string | RegExp

    run test names with the specified pattern

    testTimeout?: number

    Default timeout of a test in milliseconds

    5000
    

    Options for configuring typechecking test environment.

    ui?: boolean

    Enable Vitest UI

    false
    
    uiBase?: string

    Base url for the UI

    '/__vitest__/'
    
    unstubEnvs?: boolean

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

    false
    
    unstubGlobals?: boolean

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

    false
    
    update?: boolean

    Update snapshot

    false
    
    vmMemoryLimit?: string | number

    Specifies the memory limit for worker_thread or child_process before they are recycled. If you see memory leaks, try to tinker this value.

    watch?: boolean

    Watch mode

    !process.env.CI
    
    watchTriggerPatterns?: WatcherTriggerPattern[]

    Pattern configuration to rerun only the tests that are affected by the changes of specific files in the repository.