feat: add Vitest unit testing infrastructure with initial test suite.

This commit is contained in:
Xiaohan-Tian
2025-09-03 22:15:05 -07:00
parent be39392aee
commit aa2b19966b
11 changed files with 2673 additions and 13 deletions
+59
View File
@@ -0,0 +1,59 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
test: {
// Use jsdom environment for DOM testing
environment: 'jsdom',
// Global test setup
setupFiles: ['./src/test/setup.ts'],
// Include unit test files co-located with source
include: [
'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'
],
// Exclude directories
exclude: [
'node_modules',
'dist',
'.git',
'.cache',
'tests/' // Exclude integration/e2e folder for now
],
// Enable global test functions (describe, it, expect)
globals: true,
// Coverage configuration
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'src/test/',
'**/*.d.ts',
'**/*.config.ts',
'src/main.tsx',
'src/vite-env.d.ts'
],
thresholds: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
}
},
// Test timeout
testTimeout: 10000,
// Retry failed tests once
retry: 1
}
})