47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { Test, TestingModule } from '@nestjs/testing';
|
|
import { INestApplication } from '@nestjs/common';
|
|
import request from 'supertest';
|
|
import type { App } from 'supertest/types';
|
|
import { AppModule } from './../src/app.module';
|
|
|
|
describe('AppController (e2e)', () => {
|
|
let app: INestApplication<App>;
|
|
|
|
beforeEach(async () => {
|
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
imports: [AppModule],
|
|
}).compile();
|
|
|
|
app = moduleFixture.createNestApplication();
|
|
await app.init();
|
|
});
|
|
|
|
it('/ (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/')
|
|
.expect(200)
|
|
.expect('Hello World!');
|
|
});
|
|
|
|
it('/health (GET)', () => {
|
|
return request(app.getHttpServer())
|
|
.get('/health')
|
|
.expect(200)
|
|
.expect({ status: 'ok' });
|
|
});
|
|
|
|
it('/ready (GET) reports the database and Redis', async () => {
|
|
const response = await request(app.getHttpServer())
|
|
.get('/ready')
|
|
.expect(200);
|
|
expect(response.body.info).toMatchObject({
|
|
database: { status: 'up' },
|
|
redis: { status: 'up' },
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|