userquin / vitest-jetbrains-plugin

Vitest JetBrains plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vitest-jetbrains-plugin

A simple WebStorm plugin to run Vitest tests.

  • Green Run icon means to run once only
  • Vitest Run icon means to run with watch mode
  • Test failure detection to remark run icon as red
  • Vitest json reporter integration by .vitest-result.json file
  "scripts": {
    "test": "vitest --watch",
    "webstorm-integration": "vitest --watch --reporter=dot --reporter=json --outputFile=.vitest-result.json",
  },
  • Vitest toolWindow to display test statistics from .vitest-result.json file

Please install Awesome Console for code link/navigation from console.

Screenshot

Vitest

Attention

This plugin just a temp solution before official Vitest support from WebStorm. I think JetBrains people will do this job, and they know Vitest is great framework. For Vitest support in WebStorm, please vote here: https://youtrack.jetbrains.com/issue/WEB-54437

Vitest global support

Please enable globals: true for test in vite.config.ts: not vitest.config.ts

// vite.config.ts
import {defineConfig} from 'vitest/config'

export default defineConfig({
    test: {
        globals: true,
    },
})

Attention: Please reload(close/open) project if you enable globals: true first time.

How to debug Vitest tests?

Now Vitest plugin doesn't support Vitest test debug, but you can debug Vitest tests by running npm scripts with debug mode in WebStorm.

  "scripts": {
    "debug-demo": "vitest -t 'demo' test/demo.test.ts",
    "webstorm-integration": "vitest --watch --reporter=dot --reporter=json --outputFile=.vitest-result.json",
  },

You can run webstorm-integration from WebStorm with debug mode, then you can debug all test methods.

Or you can use standard Node.js app run configuration to debug test file, please refer https://vitest.dev/guide/debugging.html#intellij-idea

Installation

References

About

Vitest JetBrains plugin

License:Apache License 2.0


Languages

Language:Kotlin 98.5%Language:TypeScript 1.5%