13 lines
507 B
TypeScript
13 lines
507 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import request from 'supertest';
|
|
import { createApp } from '../src/app.js';
|
|
|
|
describe('health', () => {
|
|
it('ok (200 if DB reachable, 503 if not — both acceptable, never 500)', async () => {
|
|
const res = await request(createApp()).get('/api/health');
|
|
// 单元环境无容器连不上 → 503;有容器 → 200。两者都算通过(只杜绝 500 崩)
|
|
expect([200, 503]).toContain(res.status);
|
|
expect(res.body).toHaveProperty('ok');
|
|
});
|
|
});
|