title: Do not pass e2e tests in framework NestJS
body: <p>I use the <strong>NestJS</strong> framework. When using <strong>@nestjs/typeorm</strong>, I create a repository with users. Using this approach to creating a repository, my <strong>e2e tests</strong>. When working with a database, all data is successfully saved. There are no problems with the connection. Here are my files:</p>
  <p><strong>app.module.ts</strong></p>
  <pre><code>import { Module } from '@nestjs/common';
  import { TypeOrmModule } from '@nestjs/typeorm';
  import { Connection } from 'typeorm';
  import { AuthModule } from './modules/auth/auth.module';
  
  @Module({
    imports: [
      TypeOrmModule.forRoot(),
      AuthModule,
    ],
  })
  export class AppModule {
    constructor(private readonly connection: Connection) { }
  }
  </code></pre>
  <p><strong>auth.module.ts</strong></p>
  <pre><code>import { Module } from '@nestjs/common';
  import { TypeOrmModule } from '@nestjs/typeorm';
  import { AuthService } from './auth.service';
  import { AuthController } from './auth.controller';
  import { Users } from '../../entity/Users';
  
  @Module({
    imports: [TypeOrmModule.forFeature([Users])],
    controllers: [AuthController],
    providers: [AuthService],
  })
  export class AuthModule {}
  </code></pre>
  <p><strong>auth.service.ts</strong></p>
  <pre><code>...
        // my repo
        constructor(
          @InjectRepository(Users)
          private readonly usersRepository: Repository&lt;Users&gt;,
        ) { }
  ...
  </code></pre>
  <p><strong>app.e2e-spec.ts</strong></p>
  <pre><code>import { INestApplication } from '@nestjs/common';
  import { Test } from '@nestjs/testing';
  import * as request from 'supertest';
  import { AppModule } from './../src/app.module';
  
  describe('AppController (e2e)', () =&gt; {
    let app: INestApplication;
  
    beforeAll(async () =&gt; {
      const moduleFixture = await Test.createTestingModule({
        imports: [AppModule],
      }).compile();
  
      app = moduleFixture.createNestApplication();
      await app.init();
    });
  
    it('/ (GET)', () =&gt; {
      return request(app.getHttpServer())
        .get('/')
        .expect(404)
        .expect('{&quot;statusCode&quot;:404,&quot;error&quot;:&quot;Not Found&quot;,&quot;message&quot;:&quot;Cannot GET /&quot;}'); //todo fix me
    });
  });
  </code></pre>
  <p>Everything is written in accordance with the documentation. When you run <strong>npm run test:e2e</strong>, the console gives the following error:</p>
  <pre><code>&gt; project@0.0.0 test:e2e 
  &gt; jest --config ./test/jest-e2e.json
  
  [Nest] 7206   - 2/2/2019, 5:06:52 PM   [TypeOrmModule] Unable to connect to the database. Retrying (1)...
  Error: getaddrinfo ENOTFOUND postgres postgres:5432
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
  [Nest] 7206   - 2/2/2019, 5:06:55 PM   [TypeOrmModule] Unable to connect to the database. Retrying (2)... +3234ms
  Error: getaddrinfo ENOTFOUND postgres postgres:5432
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
   FAIL  test/app.e2e-spec.ts (6.198s)
    AppController (e2e)
      ✕ / (GET) (6ms)
  
    ● AppController (e2e) › / (GET)
  
      Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
  
        at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)
  
    ● AppController (e2e) › / (GET)
  
      TypeError: Cannot read property 'getHttpServer' of undefined
  
        17 |
        18 |   it('/ (GET)', () =&gt; {
      &gt; 19 |     return request(app.getHttpServer())
           |                        ^
        20 |       .get('/')
        21 |       .expect(404)
        22 |       .expect('{&quot;statusCode&quot;:404,&quot;error&quot;:&quot;Not Found&quot;,&quot;message&quot;:&quot;Cannot GET /&quot;}'); // todo fix me
  
        at Object.&lt;anonymous&gt; (app.e2e-spec.ts:19:24)
  </code></pre>
  <p>Please, help me!</p>