42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import request from 'supertest';
|
|
import { App } from 'supertest/types';
|
|
import { configureApp } from './../src/app.setup';
|
|
import { AppModule } from './../src/app.module';
|
|
import { ConnectionService } from './../src/modules/global/database/connection.service';
|
|
import { REDIS_CLIENT } from './../src/modules/global/redis/redis.constants';
|
|
|
|
describe('AppController (e2e)', () => {
|
|
let app: INestApplication<App>;
|
|
|
|
beforeEach(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
})
|
|
.overrideProvider(ConnectionService)
|
|
.useValue({})
|
|
.overrideProvider(REDIS_CLIENT)
|
|
.useValue({
|
|
destroy: jest.fn(),
|
|
quit: jest.fn().mockResolvedValue(undefined),
|
|
})
|
|
.compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
configureApp(app);
|
|
await app.init();
|
|
});
|
|
|
|
it('/api/health (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/api/health')
|
|
.expect(200)
|
|
.expect({ status: 'ok' });
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|