home / skills / ehtbanton / claudeskillsrepo / vitest-config-generator

vitest-config-generator skill

/vitest-config-generator

This skill generates a complete Vitest configuration file (vitest.config.ts) with test environment, coverage, and setup for fast unit tests.

npx playbooks add skill ehtbanton/claudeskillsrepo --skill vitest-config-generator

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
944 B
---
name: vitest-config-generator
description: Generate Vitest configuration files for fast unit testing of JavaScript/TypeScript projects. Triggers on "create vitest config", "generate vitest configuration", "vitest setup", "unit test config".
---

# Vitest Config Generator

Generate Vitest configuration files for fast unit and integration testing.

## Output Requirements

**File Output:** `vitest.config.ts`
**Format:** Valid Vitest configuration
**Standards:** Vitest 1.x

## When Invoked

Immediately generate a complete Vitest configuration with test environment, coverage, and setup files.

## Configuration Template

```typescript
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    globals: true,
    environment: 'jsdom',
  },
});
```

## Example Invocations

**Prompt:** "Create vitest config for React with coverage"
**Output:** Complete `vitest.config.ts` with jsdom and coverage settings.

Overview

This skill generates complete Vitest configuration files (vitest.config.ts) for fast unit and integration testing in JavaScript and TypeScript projects. It creates valid Vitest 1.x configurations with sensible defaults for environment, globals, coverage, and setup files. Use it to quickly scaffold test configs for frameworks like React or plain Node projects.

How this skill works

When triggered, the skill outputs a ready-to-use vitest.config.ts file that conforms to Vitest 1.x syntax. It selects test environment (jsdom or node), toggles globals, and can include coverage settings, setup files, and common aliases. The generated config is minimal by default but can be expanded to include reporters, transform options, or custom hooks.

When to use it

  • Starting a new JavaScript/TypeScript project and you need a test runner config.
  • Adding unit tests to a React app and you want jsdom plus coverage enabled.
  • Converting a Jest setup to Vitest and you need a baseline configuration.
  • Quickly scaffolding CI-friendly test settings with coverage thresholds.
  • Creating an integration test environment that needs specific setup files.

Best practices

  • Choose 'jsdom' for browser-like tests (React) and 'node' for pure backend tests.
  • Enable globals when using describe/it/test without importing them in every file.
  • Add a setup file to initialize test utilities, mocks, or global state.
  • Include coverage config and thresholds in CI to prevent regressions.
  • Keep the config minimal and add transforms or plugins only as needed.

Example use cases

  • Create vitest config for React with jsdom, globals, and coverage enabled.
  • Generate a Node-focused config with environment set to 'node' and no jsdom.
  • Add a setupFiles option to initialize testing-library or global mocks.
  • Produce a CI-ready config that outputs coverage reports in lcov and text formats.
  • Generate TypeScript-aware config with proper module resolution and alias support.

FAQ

What file does this skill produce?

It produces a vitest.config.ts file with valid Vitest 1.x configuration.

Which environment should I choose for React?

Use 'jsdom' for React to simulate a browser environment; use 'node' for backend code.

Can it enable coverage automatically?

Yes. The generated config can include coverage settings and common report formats.