mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
37 lines
827 B
TypeScript
37 lines
827 B
TypeScript
import { INestApplication } from '@nestjs/common';
|
|
import { Test } from '@nestjs/testing';
|
|
import * as request from 'supertest';
|
|
import { ApplicationModule } from '../src/app.module';
|
|
|
|
describe('Mongoose', () => {
|
|
let server;
|
|
let app: INestApplication;
|
|
|
|
beforeEach(async () => {
|
|
const module = await Test.createTestingModule({
|
|
imports: [ApplicationModule],
|
|
}).compile();
|
|
|
|
app = module.createNestApplication();
|
|
server = app.getHttpServer();
|
|
await app.init();
|
|
});
|
|
|
|
it(`should return created entity`, () => {
|
|
const cat = {
|
|
name: 'Nest',
|
|
age: 20,
|
|
breed: 'Awesome',
|
|
};
|
|
return request(server)
|
|
.post('/cats')
|
|
.send(cat)
|
|
.expect(201)
|
|
.expect(({body}) => body.name === cat.name);
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await app.close();
|
|
});
|
|
});
|