-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.spec.ts
29 lines (25 loc) · 895 Bytes
/
app.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { AppModule } from './app.module';
describe('AppController (e2e)', () => {
let app: INestApplication;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init();
});
describe('E2e test', () => {
[['/', 200, { success: true }]].forEach(
([endpoint, expectedStatus, expectedBody]: any) => {
it(`GET ${endpoint}`, async () => {
const response = await request(app.getHttpServer()).get(endpoint);
expect(response.statusCode).toEqual(expectedStatus);
expect(response.body).toEqual(expectedBody);
});
},
);
});
});