linux-china / vitest-jetbrains-plugin

Vitest JetBrains plugin
https://plugins.jetbrains.com/plugin/19220-vitest-runner
Apache License 2.0
52 stars 6 forks source link
vitest

vitest-jetbrains-plugin

Deprecated: from WebStorm 2022.3 Beta, Vitest support by default. Please refer https://blog.jetbrains.com/webstorm/2022/11/webstorm-2022-3-beta/#Vitest_support

A simple WebStorm plugin to run Vitest tests.

  "scripts": {
    "test": "vitest --watch",
    "webstorm-integration": "vitest --watch --reporter=dot --reporter=json --outputFile=.vitest-result.json",
  },

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

How Vitest Runner plugin resolves working directory?

Attention: for mono repository with subprojects independent, working directory will be subproject's directory, and Vitest Runner will use vite.config.js inside subproject.

Vitest debug support

{
  "devDependencies": {
   "c8": "^7.12.0"
  }
}

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 Vitest configuration file.

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

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

Exclude jest: jest is removed from the devDependencies, anyway, jest still resolved and installed by co dependency during npm install. You can use following solution to exclude jest:

"scripts": {
    "postinstall": "rm -rf node_modules/jest*; rm -rf node_modules/@jest"
}

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

Installation

References