1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-13 11:17:26 +02:00
unleash.unleash/src/lib/routes/health-check.test.ts
Gastón Fournier abe160eb7d
feat: Unleash v7 ESM migration (#9877)
We're migrating to ESM, which will allow us to import the latest
versions of our dependencies.

Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
2025-05-14 09:47:12 +02:00

45 lines
1.2 KiB
TypeScript

import supertest, { type Test } from 'supertest';
import { createServices } from '../services/index.js';
import { createTestConfig } from '../../test/config/test-config.js';
import createStores from '../../test/fixtures/store.js';
import getLogger from '../../test/fixtures/no-logger.js';
import getApp from '../app.js';
import type TestAgent from 'supertest/lib/agent.d.ts';
async function getSetup() {
const stores = createStores();
const config = createTestConfig();
const services = createServices(stores, config);
const app = await getApp(config, stores, services);
return {
request: supertest(app),
stores,
};
}
let request: TestAgent<Test>;
beforeEach(async () => {
const setup = await getSetup();
request = setup.request;
});
afterEach(() => {
getLogger.setMuteError(false);
});
test('should give 200 when ready', async () => {
await request.get('/health').expect(200);
});
test('should give health=GOOD when ready', async () => {
expect.assertions(2);
await request
.get('/health')
.expect(200)
.expect((res) => {
expect(res.status).toBe(200);
expect(res.body.health).toBe('GOOD');
});
});