chore: add vitest testing infrastructure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-03-23 09:13:01 +01:00
parent c0b8a94210
commit 5b56fc4dff
6 changed files with 997 additions and 3 deletions

6
.env.test.example Normal file
View File

@@ -0,0 +1,6 @@
DATABASE_URL=mysql://user:password@127.0.0.1:3306/app_test
JWT_SECRET=test-jwt-secret-do-not-use-in-production
TOTP_ENCRYPTION_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
APP_ENV=local
PORT=3099
HOST=127.0.0.1

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
node_modules/ node_modules/
dist/ dist/
.env .env
.env.test
*.log *.log
dist-client/ dist-client/
*.css.map *.css.map

971
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,7 +15,9 @@
"db:generate": "prisma generate", "db:generate": "prisma generate",
"db:pull": "prisma db pull", "db:pull": "prisma db pull",
"db:push": "prisma db push", "db:push": "prisma db push",
"db:studio": "prisma studio" "db:studio": "prisma studio",
"test": "vitest run",
"test:watch": "vitest"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
@@ -53,10 +55,13 @@
"@types/nodemailer": "^7.0.11", "@types/nodemailer": "^7.0.11",
"@types/react": "^19.2.14", "@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3", "@types/react-dom": "^19.2.3",
"@types/supertest": "^7.2.0",
"@vitejs/plugin-react": "^6.0.1", "@vitejs/plugin-react": "^6.0.1",
"concurrently": "^9.2.1", "concurrently": "^9.2.1",
"supertest": "^7.2.2",
"tsx": "^4.21.0", "tsx": "^4.21.0",
"typescript": "^5.9.3", "typescript": "^5.9.3",
"vite": "^8.0.0" "vite": "^8.0.0",
"vitest": "^4.1.0"
} }
} }

2
src/__tests__/setup.ts Normal file
View File

@@ -0,0 +1,2 @@
import dotenv from 'dotenv';
dotenv.config({ path: '.env.test' });

11
vitest.config.ts Normal file
View File

@@ -0,0 +1,11 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
environment: 'node',
setupFiles: ['./src/__tests__/setup.ts'],
testTimeout: 15000,
hookTimeout: 15000,
},
});