mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 15:08:37 +00:00
40 lines
1011 B
TypeScript
40 lines
1011 B
TypeScript
import { HttpStatus, INestApplication } from '@nestjs/common';
|
|
import { Test } from '@nestjs/testing';
|
|
import * as request from 'supertest';
|
|
import { ErrorsController } from '../src/errors/errors.controller';
|
|
|
|
describe('Error messages', () => {
|
|
let server;
|
|
let app: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
const module = await Test.createTestingModule({
|
|
controllers: [ErrorsController],
|
|
}).compile();
|
|
|
|
app = module.createNestApplication();
|
|
server = app.getHttpServer();
|
|
await app.init();
|
|
});
|
|
|
|
it(`/GET`, () => {
|
|
return request(server).get('/sync').expect(HttpStatus.BAD_REQUEST).expect({
|
|
statusCode: 400,
|
|
error: 'Bad Request',
|
|
message: 'Integration test',
|
|
});
|
|
});
|
|
|
|
it(`/GET (Promise/async)`, () => {
|
|
return request(server).get('/async').expect(HttpStatus.BAD_REQUEST).expect({
|
|
statusCode: 400,
|
|
error: 'Bad Request',
|
|
message: 'Integration test',
|
|
});
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|