-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
48 lines (47 loc) · 2.07 KB
/
Copy pathvitest.config.ts
File metadata and controls
48 lines (47 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { defineConfig } from 'vitest/config';
import preact from '@preact/preset-vite';
/**
* Vitest config para el proyecto.
*
* Configuracion manual con el plugin oficial de Preact (en vez de heredar
* de astro/config via getViteConfig) porque getViteConfig pasa el flag
* experimental --localstorage-file de Node 22+ a Vitest, lo que rompe
* el localStorage de jsdom (.clear / .removeItem dejan de ser funciones).
*
* Con el plugin de Preact directo conseguimos JSX/TSX + alias internos,
* que es lo unico que necesitan los tests unitarios.
*/
export default defineConfig({
plugins: [preact()],
test: {
globals: true, // describe/it/expect disponibles sin importar
environment: 'jsdom',
setupFiles: ['./tests/setup.ts'],
// Excluye los e2e (los corre Playwright) y node_modules
exclude: ['**/node_modules/**', '**/dist/**', '**/.{idea,git,cache,output,temp}/**', 'tests/e2e/**'],
// Tests co-localizados (*.test.ts/*.test.tsx) o en tests/unit/
include: ['src/**/*.{test,spec}.{ts,tsx}', 'tests/unit/**/*.{test,spec}.{ts,tsx}'],
css: false, // los <style>{`...`}</style> de los componentes son strings, no nos hace falta procesarlos
coverage: {
provider: 'v8',
// text -> consola en local; lcov -> formato estandar que SonarCloud lee.
reporter: ['text', 'lcov'],
reportsDirectory: 'coverage',
// Solo medimos el codigo de la app, no los archivos de test ni los
// de infraestructura del proyecto. Sonar usa este lcov para mostrar
// % de cobertura en el dashboard y en cada PR.
include: ['src/**/*.{ts,tsx}'],
exclude: [
'**/*.test.{ts,tsx}',
'**/*.spec.{ts,tsx}',
'**/*.d.ts',
'src/env.d.ts',
// Componentes Astro (no son TS analyzables aqui)
'src/**/*.astro',
// Tipos puros sin logica
'src/domain/interfaces/**',
'src/domain/entities/**',
],
},
},
});