Skip to content

saitonakamura/vscode

 
 

Repository files navigation


Vitest for VSCode Logo

Vitest for VSCode


This extension is powered by vscode testing api.

Features

  • Run/debug vitest tests in vscode.
  • NX support (see the NX sample).
  • Watch mode is supported 🎊. Test reruns are blazing fast.
  • A @open tag can be used when filtering tests, to only show the tests open in the editor.

Watch Mode

Requirements

  • Require VSCode's version >= July 2021 (version 1.59).
  • Require Vitest's version >= v0.12.0

Config

  • vitest.enable: This plugin will try to detect whether the current project is set up with Vitest to activate itself. If detection fails, you can enable the plugin manually.
  • vitest.watchOnStartup: Whether to activate Watch mode per default when the extension starts.
  • vitest.nodeEnv: The env passed to runner process in addition to process.env
  • vitest.commandLine: The command line to start vitest tests. It should have with the ability to append extra arguments. For example npx vitest or yarn test --.(This is a workspace setting. Do not change it in the user setting directly, which will affect all the projects you open)
  • vitest.debugExclude: Automatically skip files covered by these glob patterns. Default: [\"<node_internals>/**\", \"**/node_modules/**\"]

Screenshots

Filter tests by status

Debug

Inspect console output

FAQ

How can I use it in monorepo?

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

How can I use this extension when tests are under a sub directory?

You can use VS Code command add folder to workspace to add the sub directory. The extension should work fine.

test.each is not working

Dynamic test name is not supported yet. This extension currently relies on the babel parser to calculate the positions of tests statically.

Related issue: vitest-dev#133

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.1%
  • JavaScript 1.9%