Skip to content

Latest commit

 

History

History

vitest-plugins

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

vitest-plugins

npm npm npm

Adds plugins support to Vitest.

Derived off of the excellent jest-plugins

Getting Started

Install vitest-plugins using yarn:

yarn add --dev vitest-plugins

Usage

This aids in registering globals when configured in vitest. If globals is not set to true, then this process does nothing.

In order to utilize vitest-plugins in your project, you must configure the setup to add your custom plugins. If vitest-plugins ever is merged into vitest, then this will be simpler, until then, follow the instructions below.

First, find your test config in your vite.config.js. Add a key setupFiles and point it to another file at the top-level called vitest-plugins.js.

{
  test: {
    globals: true,
    setupFiles: [
      'vitest-plugins.js'
    ]
  }
}

Inside vitest-plugins.js, write the following:

require('vitest-plugins')([
  // List all vitest-plugins here.
  'vitest-plugin-context',
  'vitest-plugin-set',
]);

This is requiring each of the plugins and including it automatically in your project.

Once installed, run vitest to run your tests and plugins should be accessible in your test files.