@apitree.cz/vitest-config
v0.8.7
Published
Vitest configuration for ApiTree projects.
Readme
Vitest Config
Vitest configuration for ApiTree projects
Installation
pnpm add --save-dev @apitree.cz/vitest-config vitestIf you want to collect code coverage, you also need to install v8 provider:
pnpm add --save-dev @vitest/coverage-v8Monorepos
Install the package in the root only, use it in multiple workspaces (see Vitest Projects).
Usage
Use one of the following configurations in your vitest.config.ts.
Base
export { base as default } from '@apitree.cz/vitest-config';React
export { react as default } from '@apitree.cz/vitest-config';⚠️ You will also need to install
jsdomfor React configuration to work.
Nest.js
export { nestjs as default } from '@apitree.cz/vitest-config';Customization
You can customize the configuration with mergeConfig function:
import { base } from '@apitree.cz/vitest-config';
import { defineConfig, mergeConfig } from 'vitest/config';
export default mergeConfig(
base,
defineConfig({
// project specific config
}),
);See Options documentation for config reference.
Vitest Projects
You can also use the configurations as a base for multiple Vitest Projects in a monorepo setup.
Start by defining root vitest.config.ts:
import { defineConfig, mergeConfig } from 'vitest/config';
export default defineConfig({
test: {
root: import.meta.dirname,
projects: ['apps*/', 'packages/*'],
},
});Then, in each project, create vitest.config.js defining specific preset (e.g. apps/react-app/vitest.config.js for an app that requires React preset):
import { react } from '@apitree.cz/vitest-config';
import { defineProject } from 'vitest/config';
export default defineProject(react);Assuming the app is named @apitree.cz/react-app, you can run Vitest for this project only:
# From monorepo root
pnpm vitest --project @apitree.cz/react-app --run
# From apps/react-app
pnpm vitest --run