mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
35 lines
900 B
TypeScript
35 lines
900 B
TypeScript
import { INestApplication } from '@nestjs/common';
|
|
import { Test } from '@nestjs/testing';
|
|
import * as request from 'supertest';
|
|
import { CatsModule } from '../../src/cats/cats.module';
|
|
import { CatsService } from '../../src/cats/cats.service';
|
|
import { CoreModule } from '../../src/core/core.module';
|
|
|
|
describe('Cats', () => {
|
|
const catsService = { findAll: () => ['test'] };
|
|
|
|
let app: INestApplication;
|
|
|
|
beforeAll(async () => {
|
|
const module = await Test.createTestingModule({
|
|
imports: [CatsModule, CoreModule],
|
|
})
|
|
.overrideProvider(CatsService)
|
|
.useValue(catsService)
|
|
.compile();
|
|
|
|
app = module.createNestApplication();
|
|
await app.init();
|
|
});
|
|
|
|
it(`/GET cats`, () => {
|
|
return request(app.getHttpServer()).get('/cats').expect(200).expect({
|
|
data: catsService.findAll(),
|
|
});
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await app.close();
|
|
});
|
|
});
|