nest-project/test/app.e2e-spec.ts

25 lines
618 B
TypeScript
Raw Normal View History

import { Test, TestingModule } from '@nestjs/testing'
import { INestApplication } from '@nestjs/common'
import * as request from 'supertest'
import { AppModule } from './../src/app.module'
2023-02-15 16:49:40 +08:00
describe('AppController (e2e)', () => {
let app: INestApplication
2023-02-15 16:49:40 +08:00
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile()
2023-02-15 16:49:40 +08:00
app = moduleFixture.createNestApplication()
await app.init()
})
2023-02-15 16:49:40 +08:00
it('/ (GET)', () => {
return request(app.getHttpServer())
.get('/')
.expect(200)
.expect('Hello World!')
})
})