Files
plantillas-proyectos/frontend/src/lib/backend.test.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

21 lines
912 B
TypeScript

import { describe, it, expect } from 'vitest'
// Solo en entorno con DNS `backend` (p. ej. red Docker) y con backend levantado; en Jenkins/CI se omite.
const skipHttpIntegration = process.env.CI === 'true' || Boolean(process.env.JENKINS_URL)
describe.skipIf(skipHttpIntegration)('backend — health check', () => {
it('el backend esta corriendo y responde', async () => {
const response = await fetch('http://backend:8000/api/health')
expect(response.status).toBe(200)
})
it('el endpoint de facturas responde', async () => {
const response = await fetch('http://backend:8000/api/v1/a76/invoices/?company_id=1', {
headers: { 'Authorization': 'Bearer test' }
})
// 200 con datos o 401/403 sin token valido — ambos significan que el backend esta vivo
expect([200, 401, 403, 422]).toContain(response.status)
})
})