Files
plantillas-proyectos/frontend/vite.config.ts
AlexeerCT 5933b161b5 Add frontend testing stage to Jenkinsfile and update Vitest configuration for CI environments
- Introduced a new 'Test frontend' stage in the Jenkinsfile to run unit tests using Vitest in a Docker container.
- Updated Vite configuration to conditionally include client and server test projects based on the CI environment.
- Modified backend health check tests to skip execution in CI environments.
- Adjusted test for constructing backend asset URLs to reflect default behavior when no base URL is provided.
2026-04-24 10:35:42 -05:00

68 lines
1.7 KiB
TypeScript

import { paraglideVitePlugin } from '@inlang/paraglide-js';
import tailwindcss from '@tailwindcss/vite';
import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';
/* Jenkins / CI: sin navegador ni pnpm exec playwright install (Vitest 3+ intenta aun levantar el project "client" si queda en la config). */
const vitestNoBrowser =
process.env.CI === 'true' ||
Boolean(process.env.JENKINS_URL) ||
process.env.VITEST_NO_BROWSER === '1';
const vitestServerProject = {
extends: './vite.config.ts',
test: {
name: 'server' as const,
environment: 'node' as const,
include: ['src/**/*.{test,spec}.{js,ts}'],
exclude: ['src/**/*.svelte.{test,spec}.{js,ts}'],
},
};
const vitestClientProject = {
extends: './vite.config.ts',
test: {
name: 'client' as const,
environment: 'browser' as const,
browser: {
enabled: true,
provider: 'playwright' as const,
instances: [{ browser: 'chromium' as const }],
},
include: ['src/**/*.svelte.{test,spec}.{js,ts}'],
exclude: ['src/lib/server/**'],
setupFiles: ['./vitest-setup-client.ts'],
},
};
export default defineConfig({
server: {
port: 5173, // fija el puerto
host: true, // escucha en 0.0.0.0
allowedHosts: [
'anexo76-dev.aduanasoft.com',
// 'otro-host.com' si necesitas más
],
proxy: {
'/api/uploads': {
target: 'http://backend:8000',
changeOrigin: true
}
}
},
plugins: [
tailwindcss(),
sveltekit(),
paraglideVitePlugin({
project: './project.inlang',
outdir: './src/lib/paraglide'
})
],
test: {
expect: { requireAssertions: true },
projects: vitestNoBrowser
? [vitestServerProject]
: [vitestClientProject, vitestServerProject]
}
});