mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import * as request from 'supertest';
|
|
import { Test } from '@nestjs/testing';
|
|
import { INestApplication, HttpStatus } from '@nestjs/common';
|
|
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();
|
|
});
|
|
});
|