Supported technologies: Vitest

Wallaby supports Vitest from v0.14.0 with node v16.12.0+.

Please report any issues or feedback to us via our github issues repository.

Select your editor

The content of this page is adjusted based on your editor of choice. Please select your editor by clicking on your editor’s logo below before proceeding:

Starting Wallaby on a project with configured Vitest

To start Wallaby in VS Code you may run Select Configuration command and then select Automatic Configuration <project directory> option once. After that you may keep using Wallaby Start command as usual and it will start Wallaby with automatic configuration.

To start Wallaby in Sublime Text you may use the Select for Wallaby.js Automatic Configuration context menu item for your project folder in the project’s file tree. After that you may keep using Wallaby Start command as usual and it will start Wallaby with automatic configuration.

To start Wallaby in Visual Studio, you may use the Start Wallaby.js (Automatic Configuration) context menu item for your project folder in the Solution Explorer. After the first start, the selected project will be remembered for your solution and Wallaby can be started with Tools->Start Wallaby.js (Alt-W, 1).

To start Wallaby in JetBrains IDEs, you may edit (or create a new) wallaby.js Run Configuration by selecting Edit configurations from the drop-down menu in the top right-hand corner of the navigation bar, or from the Run menu. In the run configuration editor set Configuration Type filed value to Automatic.

Overriding Automatic Configuration

Sometimes you may want to add/override some Wallaby configuration settings to the automatically detected settings. For example, if you want to exclude some tests when you are using Wallaby but not when you are running tests from the command-line or Continuous Integration build. You may configure an override in a configuration file or package.json section. If you are not using vitest’s default configuration file naming convention (i.e. vitest.config.ts, vite.config.ts, etc.), then you may also configure the configuration file path.

After creating Wallaby config file to override automatic defaults in VS Code you need to run Select Configuration command and then select the config file once. After that you may keep using Wallaby Start command as usual and it will start Wallaby with the configuration file.

After creating Wallaby config file to override automatic defaults in JetBrains IDEs, you may edit (or create a new) wallaby.js Run Configuration by selecting Edit configurations from the drop-down menu in the top right-hand corner of the navigation bar, or from the Run menu. In the run configuration editor set Configuration Type filed value to Configuration File.

Note that if you are adding/overriding files/tests, then you need to add the autoDetect: true setting:

module.exports = () => ({
  autoDetect: true,

  // modify `files` automatic configuration settings
  files: {
    override: (filePatterns) => {
      // TODO: modify `filePatterns` array as required
      return filePatterns;
    }
  },

  // modify `tests` automatic configuration settings
  tests: {
    override: (testPatterns) => {
      // TODO: modify `testPatterns` array as required
      return testPatterns;
    }
  }

  // specify non-standard vitest configuration file path
  testFramework: {
    configFile: './my.vitest.config.ts'
  }
});

Using pnpm

Some Wallaby internals need to dynamically load your project dependencies and patch them both at runtime and in the file system. Depending on your project type and the packages you are using, sometimes Wallaby may fail to load without modifications to your .npmrc file:

public-hoist-pattern[]=*vitest*
public-hoist-pattern[]=vite-node

Using yarn2

Wallaby may report errors about missing dependencies when using Yarn 2. For example:

Required dependency '@vitest/runner' not found.

To fix this, you will need to add any listed dependencies to your project (e.g. yarn add -D @vitest/runner).

Troubleshooting

The first step of troubleshooting a project configured to use automatic configuration is to identify whether the same results are returned using npx vitest. Running vitest from the command-line will usually show/highlight the cause of your problem.

If Wallaby is not working with vitest, then you may like to try to downgrade to an earlier version of vitest to see if that fixes your problem. If this does fix your problem, please report this issue to the Wallaby team.

If you get stuck or something isn’t working for you, you may find further troubleshooting steps here or else find a similar solved issue in our github issues repository. If you can’t find a solution, create a new issue.