Nest 12 (ESM, vitest, oxlint). El .env se valida con zod al arrancar; prefijo global /api, CORS configurable y GET /api/health. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
25 lines
703 B
TypeScript
25 lines
703 B
TypeScript
import { Test } from '@nestjs/testing';
|
|
import type { INestApplication } from '@nestjs/common';
|
|
import request from 'supertest';
|
|
import { AppModule } from '../src/app.module.js';
|
|
|
|
describe('Health (e2e)', () => {
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
const moduleRef = await Test.createTestingModule({ imports: [AppModule] }).compile();
|
|
app = moduleRef.createNestApplication();
|
|
app.setGlobalPrefix('api');
|
|
await app.init();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
|
|
it('GET /api/health responde ok', async () => {
|
|
const res = await request(app.getHttpServer()).get('/api/health').expect(200);
|
|
expect(res.body.status).toBe('ok');
|
|
});
|
|
});
|