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

View File

@@ -19,6 +19,10 @@
"lint:fix": "next lint --fix",
"preview": "next build && next start",
"start": "node server.js",
"test": "vitest",
"test:ui": "vitest --ui",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit"
},
"dependencies": {
@@ -50,18 +54,26 @@
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@tailwindcss/postcss": "^4.0.15",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/react": "^16.3.0",
"@testing-library/user-event": "^14.6.1",
"@types/node": "^24.3.1",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@vitejs/plugin-react": "^5.0.2",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/ui": "^3.2.4",
"eslint": "^9.23.0",
"eslint-config-next": "^15.2.3",
"jsdom": "^26.1.0",
"postcss": "^8.5.3",
"prettier": "^3.5.3",
"prettier-plugin-tailwindcss": "^0.6.11",
"prisma": "^6.5.0",
"tailwindcss": "^4.0.15",
"typescript": "^5.8.2",
"typescript-eslint": "^8.27.0"
"typescript-eslint": "^8.27.0",
"vitest": "^3.2.4"
},
"ct3aMetadata": {
"initVersion": "7.39.3"