djankies/claude-configs/migrating-to-vitest-4
Claude Code and agent skill by djankies/claude-configs
- community
Checking that the SKILL.md file is still in the repository.
Migrate from Vitest 2.x/3.x to 4.x with pool options, coverage config, workspace to projects, and browser mode updates. Use when upgrading Vitest versions or encountering deprecated patterns.
Install
npx vskill@latest install djankies/claude-configs/migrating-to-vitest-4SKILL.md
The same SKILL.md was published earlier as djankies/claude-configs/migrating-to-vitest-4.
Migrating to Vitest 4
This skill guides migration from Vitest 2.x/3.x to 4.x, focusing on breaking changes and deprecated patterns.
Migration Overview
Vitest 4.0 introduces breaking changes in:
- Pool Architecture: Consolidated worker configuration
- Coverage: Required explicit include patterns
- Workspace: Replaced by projects array
- Browser Mode: Separate provider packages
- Dependencies: Moved to server namespace
- Module Runner: New Vite-based implementation
Quick Migration Guide
Pool Configuration
Before (Vitest 3.x):
After (Vitest 4.x):
Coverage Configuration
Before (Vitest 3.x):
After (Vitest 4.x):
Workspace to Projects
Before (Vitest 3.x):
After (Vitest 4.x):
Browser Mode
Before (Vitest 3.x):
After (Vitest 4.x):
Import updates:
Dependencies
Before (Vitest 3.x):
After (Vitest 4.x):
For detailed migration tables covering all options, see references/migration-tables.md
Migration Workflow
Step 1: Update Package
Step 2: Update Config
- Replace
maxThreads/maxForkswithmaxWorkers - Add
coverage.includepatterns - Replace
defineWorkspacewithprojects - Move
deps.*toserver.deps.* - Update browser provider imports
Step 3: Update Test Files
Replace with:
Step 4: Install Browser Providers
If using browser mode:
Step 5: Run Tests
Check for deprecation warnings.
Step 6: Verify Coverage
For complete migration workflow with troubleshooting, see references/migration-workflow.md
Migration Checklist
Configuration
- [ ] Update
vitestto 4.x - [ ] Replace
maxThreads/maxForkswithmaxWorkers - [ ] Add explicit
coverage.includepatterns - [ ] Replace
defineWorkspacewithprojects - [ ] Move
deps.*toserver.deps.* - [ ] Update browser provider config
Test Files
- [ ] Update imports from
@vitest/browser/contexttovitest/browser - [ ] Remove
vitest/executeimports
Environment
- [ ] Replace
VITE_NODE_DEPS_MODULE_DIRECTORIESwithVITEST_MODULE_DIRECTORIES
Verification
- [ ] Run tests and verify no deprecation warnings
- [ ] Verify coverage reports generate correctly
Common Migration Issues
Issue: "maxThreads is not a valid option"
Solution: Replace with maxWorkers
Issue: Coverage Reports Empty
Solution: Add explicit coverage.include patterns
Issue: Workspace Config Not Working
Solution: Replace defineWorkspace with defineConfig and projects
Issue: Browser Tests Fail
Solution: Install provider package and update imports
Issue: "deps.inline is not a valid option"
Solution: Move to server.deps.inline
For detailed troubleshooting, see references/migration-workflow.md
Mock Implementation Changes
Mock Names
Returns vi.fn() instead of spy in Vitest 4.x
Invocation Order
Starts at 1 instead of 0 (matching Jest)
Restore Mocks
No longer affects automocks
Reporter Changes
Before (Vitest 3.x):
After (Vitest 4.x):
Environment Variables
Before:
After:
Default Exclusions
Vitest 3.x: Excluded many directories by default
Vitest 4.x: Only excludes node_modules and .git
Add explicit excludes if needed:
References
For detailed migration information:
- Migration Tables - Complete before/after comparisons
- Migration Workflow - Step-by-step process with troubleshooting
For new configuration patterns, see @vitest-4/skills/configuring-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
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingvitest-4/skills/migrating-to-vitest-4/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/djankies/claude-configs/migrating-to-vitest-4)