vitest.config.ts in Vitest

From the Vitest cheat sheet ยท Setup & Configuration ยท verified Nov 2026

vitest.config.ts

Configure Vitest with defineConfig, reuse your Vite config, and extend the defaults

typescript
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    environment: 'node',
    include: ['src/**/*.test.ts'],
    setupFiles: ['./vitest.setup.ts'],
    testTimeout: 5_000,
  },
})
๐Ÿ“Œ A vitest.config.ts overrides vite.config.ts; merge them to keep plugins
โš ๏ธ Setting include or exclude replaces the defaults; spread configDefaults
๐Ÿ’ก Vite options like plugins and resolve.alias go at the top level
๐Ÿ” process.env.VITEST is set, so vite.config can branch for tests
configdefineConfig

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet