File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 11import { Test , TestingModule } from '@nestjs/testing' ;
22import * as request from 'supertest' ;
33import { AppModule } from './../src/app.module' ;
4- import { INestApplication } from '@nestjs/common' ;
4+ import { INestApplication , ValidationPipe } from '@nestjs/common' ;
55import { Sequelize } from 'sequelize-typescript' ;
6+ import { ConfigService } from 'src/shared/config/config.service' ;
7+ import { Post } from './../src/posts/post.entity' ;
8+ import { User } from './../src/users/user.entity' ;
69
710describe ( '/' , ( ) => {
811 let app : INestApplication ;
912 let sequelize : Sequelize ;
13+
14+ beforeAll ( async ( ) => {
15+ const module = await Test . createTestingModule ( {
16+ imports : [ AppModule ] ,
17+ providers : [
18+ {
19+ provide : 'SEQUELIZE' ,
20+ useFactory : ( configService : ConfigService ) => {
21+ sequelize = new Sequelize (
22+ configService . sequelizeOrmConfig ,
23+ ) ;
24+
25+ sequelize . addModels ( [ User , Post ] ) ;
26+
27+ return sequelize ;
28+ } ,
29+ inject : [ ConfigService ] ,
30+ } ,
31+ ] ,
32+ } ) . compile ( ) ;
33+
34+ app = module . createNestApplication ( ) ;
35+ app . useGlobalPipes ( new ValidationPipe ( ) ) ;
36+ await app . init ( ) ;
37+ } ) ;
1038} ) ;
You can’t perform that action at this time.
0 commit comments