vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
728 stars 79 forks source link
testing vitest vscode

Vitest extension for Visual Studio Code logo

Vitest extension for Visual Studio Code. Available on Visual Studio Marketplace.

Features

Requirements

Usage

You can manage tests both from the Testing view and directly within your test files.

In the Testing View

Testing view

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).

In the Test File

Vitest test file

When viewing a test file, you'll notice test icons in the gutter next to each test case:

Configuration

You can identify if your config is loaded by the extension with process.env.VITEST_VSCODE and change the configuration accordingly.

Workspace Configurations

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.

Other Options

FAQs (Frequently Asked Questions)

How can I use it in monorepo?

See https://vitest.dev/guide/workspace.html for monorepo support.

How to hide Test Results view when running tests

You can change the behaviour of testing view by modifying testing.openTesting option:

This is a vscode's built-in option and will control every plugin.