import { Test , TestingModule } from '@nestjs/testing' ; import * as request from 'supertest' ; import { AppModule } from '../src/app.module' ; import { NestExpressApplication } from '@nestjs/platform-express' ; import { join } from 'path' ; describe ( 'AppController (e2e)' , ( ) => { let app ; beforeEach ( async ( ) => { const moduleFixture = await Test . createTestingModule ( { imports : [ AppModule ] , } ) . compile ( ) ; app = moduleFixture . createNestApplication < NestExpressApplication > ( ) ; app . setBaseViewsDir ( join ( process . cwd ( ) , 'public' ) ) ; app . setViewEngine ( 'hbs' ) ; await app . init ( ) ; } ) ; it ( '/ (GET)' , ( ) => { return request ( app . getHttpServer ( ) ) . get ( '/' ) . expect ( 200 ) . expect ( `<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>App</title>
  </head>
  <body>
    Hello World!
  </body>
</html>
` ) ; } ) ; } ) ;