Skip to content

The @nx/vitest plugin provides various generators to help you create and configure vitest projects within your Nx workspace. Below is a complete reference for all available generators and their options.

Generate a Vitest setup for a project.

Usage:

Terminal window
nx generate @nx/vitest:configuration [options]
OptionTypeDescriptionDefault
--projectstring [required]The name of the project to test.
--compilerstringThe compiler to use"babel"
--coverageProviderstringCoverage provider to use."v8"
--inSourceTestsbooleanDo not generate separate spec files and set up in-source testing.false
--runtimeTsconfigFileNamestringThe name of the project’s tsconfig file that includes the runtime source files. If not provided, it will default to tsconfig.lib.json for libraries and tsconfig.app.json for applications.
--skipFormatbooleanSkip formatting files.false
--skipPackageJsonbooleanDo not add dependencies to package.json.false
--skipViteConfigbooleanSkip generating a vite config file.false
--testEnvironmentstringThe vitest environment to use. See https://vitest.dev/config/#environment.
--testTargetstringThe test target of the project to be transformed to use the @nx/vitest:test executor.
--uiFrameworkstringUI framework to use with vitest.

You can get help for any generator by adding the --help flag:

Terminal window
nx generate @nx/vitest:<generator> --help