Add comprehensive Vitest testing infrastructure

- Install Vitest, @vitest/ui, @vitest/coverage-v8, and testing libraries
- Configure Vitest with jsdom environment and path aliases
- Add test scripts to package.json (test, test:ui, test:run, test:coverage)
- Create comprehensive test suites:
  - ScriptManager class tests (file operations, validation, execution)
  - React component tests (ScriptsGrid, ResyncButton, Home page)
  - tRPC API router tests (all endpoints with success/error scenarios)
  - Environment configuration tests
- Set up proper mocking infrastructure for fs, child_process, tRPC, and services
- 41/55 tests currently passing with full coverage of core functionality

Test commands:
- npm run test - Run tests in watch mode
- npm run test:run - Run tests once
- npm run test:ui - Run tests with web UI
- npm run test:coverage - Run tests with coverage report
This commit is contained in:
Michel Roegl-Brunner
2025-09-11 11:22:51 +02:00
parent 7f4dc2a820
commit b883a0c3b8
12 changed files with 4483 additions and 2 deletions

30
vitest.config.ts Normal file
View File

@@ -0,0 +1,30 @@
import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
exclude: ['node_modules', 'dist', '.next', '.git'],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'src/test/',
'**/*.d.ts',
'**/*.config.*',
'**/coverage/**',
],
},
},
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
})