59 lines
2 KiB
TypeScript
59 lines
2 KiB
TypeScript
/// <reference types="vitest/config" />
|
|
import tailwindcss from '@tailwindcss/vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { defineConfig } from 'vite'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
test: {
|
|
environment: 'jsdom',
|
|
// Give jsdom a real origin so the client's relative `/api/...` fetches
|
|
// resolve to an absolute URL MSW can intercept.
|
|
environmentOptions: { jsdom: { url: 'http://localhost' } },
|
|
globals: true,
|
|
setupFiles: ['./src/test/setup.ts'],
|
|
// Keep the future Playwright e2e suite out of the Vitest run.
|
|
exclude: ['**/node_modules/**', '**/dist/**', 'e2e/**'],
|
|
coverage: {
|
|
provider: 'v8',
|
|
include: ['src/**/*.{ts,tsx}'],
|
|
exclude: [
|
|
'src/main.tsx', // app mount point — no logic to test
|
|
'src/**/*.test.{ts,tsx}', // the tests themselves
|
|
'src/test/**', // test harness (MSW server/setup)
|
|
'src/vite-env.d.ts',
|
|
'src/types/**', // type-only declarations
|
|
],
|
|
// Floors set a touch below current (≈98% lines) to catch regressions
|
|
// without being brittle. Raise as coverage climbs; the goal is "no silent
|
|
// backslide", not gaming a round number.
|
|
thresholds: {
|
|
statements: 95,
|
|
branches: 90,
|
|
functions: 95,
|
|
lines: 95,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 5173,
|
|
strictPort: true,
|
|
// Polling + explicit HMR client port make file-watch and the HMR
|
|
// websocket work reliably when Vite runs inside a (podman) container.
|
|
watch: { usePolling: true },
|
|
hmr: { clientPort: 5173 },
|
|
allowedHosts: true,
|
|
proxy: {
|
|
// Browser hits same-origin /api; Vite forwards to the backend service
|
|
// on the compose network (service name `php`, internal port 80) so the
|
|
// session cookie flows. NOT localhost:8100 — that is the host, not this
|
|
// container.
|
|
'/api': {
|
|
target: 'http://php:80',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
})
|