import { Test , TestingModule } from '@nestjs/testing' ; import * as request from 'supertest' ; import { AppModule } from '../src/app.module' ; import { INestApplication } from '@nestjs/common' ; const requestFunction = ( url , data , app ) => request ( app . getHttpServer ( ) ) . get ( url ) . expect ( 200 ) . expect ( data ) ; describe ( 'AppController (e2e)' , ( ) => { let app ; beforeEach ( async ( ) => { const module = await Test . createTestingModule ( { imports : [ AppModule ] , } ) . compile ( ) ; app = module . createNestApplication ( ) ; await app . init ( ) ; } ) ; describe ( '/ (GET)' , ( ) => { it ( '/ (GET)' , ( ) => { return requestFunction ( '/' , 'Hello, World!' , app ) ; } ) ; it ( '/?name=Tester' , ( ) => { return requestFunction ( '/?name=Tester' , 'Hello, Tester!' , app ) ; } ) ; } ) ; } ) ;