app.e2e-spec.ts 710 B

1234567891011121314151617181920212223242526
  1. import { Test, TestingModule } from '@nestjs/testing';
  2. import { INestApplication } from '@nestjs/common';
  3. // import * as request from 'supertest';
  4. import request from 'supertest';
  5. import { App } from 'supertest/types';
  6. import { AppModule } from './../src/app.module';
  7. describe('AppController (e2e)', () => {
  8. let app: INestApplication<App>;
  9. beforeEach(async () => {
  10. const moduleFixture: TestingModule = await Test.createTestingModule({
  11. imports: [AppModule],
  12. }).compile();
  13. app = moduleFixture.createNestApplication();
  14. await app.init();
  15. });
  16. it('/ (GET)', () => {
  17. return request(app.getHttpServer())
  18. .get('/')
  19. .expect(200)
  20. .expect('Hello World!');
  21. });
  22. });