@open
tag can be used when filtering tests, to only show the tests open in the editor.You can manage tests both from the Testing view and directly within your test files.
Vitest uses vscode's TestController
API to provide a unified testing experience. You can read the official guide on how to run tests in the VSCode Documentation.
You can access the extension from the Testing view in the Visual Studio Code sidebar.
The toolbar at the top provides various commands to manage test execution:
💡 Hovering, or right clicking a folder, test file, test suite, or a test will reveal more actions.
The filter bar allows you to narrow down the tests displayed, focusing on specific tests by name, exclusion patterns, or tags.
Icons next to each test indicate their status—passed (checkmark), failed (cross), skipped (arrow), queued (yellow icon), or not executed (dot).
When viewing a test file, you'll notice test icons in the gutter next to each test case:
Run Test
: Execute the selected test case.Debug Test
: Start a debugging session for the selected test case.Run with coverage
: Execute the selected test case while also collecting code coverage information.Reveal in Test Explorer
: Locate and highlight the test in the centralized Testing view.Breakpoint Settings
: Set breakpoints to pause execution during debugging. You can add a standard breakpoint, a conditional breakpoint, a logpoint, or a triggered breakpoint.You can identify if your config is loaded by the extension with process.env.VITEST_VSCODE
and change the configuration accordingly.
These options are resolved relative to the workspace file if there is one. If you have a single folder open in Visual Studio Code, paths will be resolved relative to that folder. If there are multiple folders, but there is no workspace file, then paths are resolved as is (so they should be absolute) - this can happen if you change your user config to have multiple folders.
vitest.rootConfig
: The path to your root config file. If you have several Vitest configs, consider using a Vitest workspace.vitest.workspaceConfig
: The path to the Vitest workspace config file. You can only have a single workspace config per VSCode workspace.vitest.configSearchPatternExclude
: Glob pattern that should be ignored when this extension looks for config files. Note that this is applied to config files, not test files inside configs. Default: {**/node_modules/**,**/.*/**,*.d.ts}
. If the extension cannot find Vitest, please open an issue.vitest.shellType
: The method the extension uses to spawn a long-running Vitest process. This is particularly useful if you are using a custom shell script to set up the environment. When using the terminal
shell type, the websocket connection will be established. Can either be terminal
or child_process
. Default: child process
.vitest.nodeExecutable
: The path to the Node.js executable. If not assigned, tries to find Node.js path via a PATH variable or a which
command. This is applied only when vitest.shellType
is child_process
(the default).vitest.nodeExecArgs
: The arguments to pass to the Node.js executable. This is applied only when vitest.shellType
is child_process
(the default).vitest.terminalShellPath
: The path to the shell executable. This is applied only when vitest.shellType
is terminal
.vitest.terminalShellArgs
: The arguments to pass to the shell executable. This is applied only when vitest.shellType
is terminal
.vitest.debuggerPort
: Port that the debugger will be attached to. By default uses 9229 or tries to find a free port if it's not available.vitest.debuggerAddress
: TCP/IP address of process to be debugged. Default: localhost💡 The
vitest.nodeExecutable
andvitest.nodeExecArgs
settings are used asexecPath
andexecArgv
when spawning a newchild_process
, and asruntimeExecutable
andruntimeArgs
when debugging a test. Thevitest.terminalShellPath
andvitest.terminalShellArgs
settings are used asshellPath
andshellArgs
when creating a new terminal
vitest.filesWatcherInclude
: Glob pattern for the watcher that triggers a test rerun or collects changes. Default: **/*
vitest.vitestPackagePath
: The path to a package.json
file of a Vitest executable (it's usually inside node_modules
) in case the extension cannot find it. It will be used to resolve Vitest API paths. This should be used as a last resort fix.vitest.nodeEnv
: Environment passed to the runner process in addition to
process.env
vitest.debugExclude
: Excludes files matching specified glob patterns from debugging. Default:
[\"<node_internals>/**\", \"**/node_modules/**\"]
vitest.maximumConfigs
: The maximum amount of configs that Vitest extension can load. If exceeded, the extension will show a warning suggesting to use a workspace config file. Default: 3
vitest.logLevel
: How verbose should the logger be in the "Output" channel. Default: info
You can reveal the current test file in the test explorer view by selecting the "Reveal in Test Explorer" option (the last option on the screenshot) in the file context:
You can also type the same command in the quick picker while the file is open.
If the extension hangs, consider enabling vitest.experimentalStaticAstCollect
option to use static analysis instead of actually running the test file every time you make a change which can cause visible hangs if it takes a long time to setup the test.
See https://vitest.dev/guide/workspace.html for monorepo support.
You can change the behaviour of testing view by modifying testing.openTesting
option:
neverOpen
will never open the testing viewopenOnTestStart
(default) opens the test results view when test starts runningopenOnTestFailure
opens the test results view if at least one of test failsopenExplorerOnTestStart
will open the test tree view when tests startsThis is a vscode's built-in option and will control every plugin.
vitest.shellType: terminal
, but I don't see the terminalThe extension uses a modified Vitest script that removes the reporter output. For this reason, the terminal is hidden by default. However, it might be useful to debug issues with the extension or Vitest itself - to open the terminal in the "Terminals" view you can use the "Vitest: Show Shell Terminal" command.