xiaohongshu
xiaohongshu
configuring-vitest-4
Configure Vitest 4.x with correct pool architecture, coverage settings, and multi-project setup. Use when creating or modifying vitest.config files or setting up test infrastructure.
Full skill instructions
This skill teaches correct Vitest 4.x configuration patterns, focusing on the breaking changes introduced in version 4.0.
Vitest 4.0 introduced major configuration changes:
maxWorkersinclude patternsprojects array instead of workspaceserver.deps namespaceimport { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
pool: 'forks',
maxWorkers: 4,
isolate: true,
fileParallelism: true,
},
});
Key changes from Vitest 3.x:
maxThreads → maxWorkersmaxForks → maxWorkerssingleThread: true → maxWorkers: 1, isolate: falseFor detailed pool configuration options, see references/pool-configuration.md
export default defineConfig({
test: {
coverage: {
provider: 'v8',
reporter: ['text', 'html'],
include: ['src/**/*.{ts,tsx}'],
},
},
});
Required: Coverage now requires explicit include patterns.
For detailed coverage configuration, see references/coverage-configuration.md
For testing Zod schema coverage, use the testing-zod-schemas skill for patterns on validation logic testing, ensuring 100% branch coverage.
export default defineConfig({
test: {
projects: [
{
test: {
name: 'unit',
include: ['tests/unit/**/*.test.ts'],
environment: 'node',
},
},
{
test: {
name: 'integration',
include: ['tests/integration/**/*.test.ts'],
testTimeout: 30000,
},
},
],
},
});
Key change: defineWorkspace replaced by projects in defineConfig
For detailed multi-project configuration, see references/multi-project-setup.md
For testing Next.js server actions with Vitest, use the securing-server-actions skill for patterns on authentication, validation, and security testing.
import { playwright } from '@vitest/browser-playwright';
export default defineConfig({
test: {
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium' }],
},
},
});
Key changes:
browser.name → browser.instances arrayFor detailed browser mode configuration, see references/browser-mode-config.md
export default defineConfig({
test: {
server: {
deps: {
inline: ['vue', 'lodash-es'],
external: ['aws-sdk'],
},
},
},
});
Key change: deps.* moved to server.deps.*
export default defineConfig({
test: {
environment: 'node',
},
});
export default defineConfig({
test: {
environment: 'jsdom',
},
});
Or use happy-dom for better performance:
export default defineConfig({
test: {
environment: 'happy-dom',
},
});
For configuring Vitest to test React components, use the testing-components skill for setup patterns and testing @testing-library/react with React 19 components.
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['src/**/*.test.ts'],
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
},
},
});
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
},
});
Use projects for different test types:
export default defineConfig({
test: {
projects: [
{ test: { name: 'unit', environment: 'node' } },
{ test: { name: 'component', environment: 'jsdom' } },
{ test: { name: 'browser', browser: { enabled: true } } },
],
},
});
For complete configuration examples, see references/complete-examples.md
After creating config, verify with:
vitest --run
Check for deprecation warnings in output. If warnings appear, consult migration guide.
Never use these (removed in Vitest 4.0):
maxThreads → Use maxWorkersmaxForks → Use maxWorkerssingleThread → Use maxWorkers: 1, isolate: falsepoolOptions → Flatten to top-levelcoverage.ignoreEmptyLines → No longer neededcoverage.all → Use explicit includecoverage.extensions → Use explicit includedefineWorkspace → Use defineConfig with projectspoolMatchGlobs → Use projects with includeenvironmentMatchGlobs → Use projects with environmentdeps.inline → Use server.deps.inlinedeps.external → Use server.deps.externalbrowser.name → Use browser.instancesbrowser.testerScripts → Use browser.testerHtmlPathmaxThreads, singleThread no longer existprojects in defineConfigexport default defineConfig({
test: {
pool: 'threads',
isolate: false,
fileParallelism: true,
maxWorkers: 4,
},
});
export default defineConfig({
test: {
browser: {
enabled: true,
provider: playwright(),
instances: [{ browser: 'chromium' }],
headless: true,
fileParallelism: true,
},
},
});
For detailed configuration documentation:
For migration from Vitest 3.x, see @vitest-4/skills/migrating-to-vitest-4
For browser mode setup, see @vitest-4/skills/using-browser-mode
For complete API reference, see @vitest-4/knowledge/vitest-4-comprehensive.md
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience