$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Scaffoldingbeginner

Vitest Config

Share

Configure Vitest testing framework

Works with OpenClaude

You are a Vitest configuration specialist. The user wants to configure Vitest as their testing framework with proper setup files, environment settings, and test discovery patterns.

What to check first

  • Run npm list vitest to confirm Vitest is installed (or npm install vitest --save-dev)
  • Check if vite.config.ts or vite.config.js exists in your project root
  • Verify your package.json has a test script field

Steps

  1. Create or open vitest.config.ts in your project root (or vitest.config.js for JavaScript projects)
  2. Import defineConfig from vitest/config and set test object with environment option (use 'node' for backend, 'jsdom' for DOM testing)
  3. Configure include and exclude patterns to specify which files Vitest should scan (e.g., **/*.test.ts, **/*.spec.ts)
  4. Set globals: true if you want describe, test, expect available without imports
  5. Add coverage object with provider: 'v8' or 'istanbul' and reporter: ['text', 'json'] for coverage reports
  6. Configure setupFiles array to point to setup scripts that run before tests (e.g., ['./vitest.setup.ts'])
  7. Add test script to package.json: "test": "vitest" and "test:ui": "vitest --ui"
  8. Run npm test to verify Vitest discovers and executes tests

Code

import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  test: {
    // Test environment: 'node', 'jsdom', 'happy-dom', or 'edge-runtime'
    environment: 'jsdom',
    
    // Auto-import test globals (describe, test, expect, etc.)
    globals: true,
    
    // Setup files that run before test suite
    setupFiles: ['./vitest.setup.ts'],
    
    // File patterns to include in test discovery
    include: ['src/**/*.{test,spec}.{js,ts,jsx,tsx}'],
    exclude: ['node_modules', 'dist'],
    
    // Coverage configuration
    coverage: {
      provider: 'v8',
      reporter: ['text', 'json', 'html'],
      exclude: [
        'node_modules/',
        'dist/',
        '**/*.spec.ts',
        '**/*.test.ts',
      ],
      lines: 80,
      functions: 80,
      branches:

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryScaffolding
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
scaffoldingvitesttesting

Install command:

curl -o ~/.claude/skills/vitest-config.md https://claude-skills-hub.vercel.app/skills/scaffolding/vitest-config.md

Related Scaffolding Skills

Other Claude Code skills in the same category — free to download.

Want a Scaffolding skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.