title: Trying to test my nest api with jest, returns undefined
body: <p>I am attempting to create a Jest test with the NestJs framework.</p>
  
  <p>The test should check the controller and service however 1) The controller is undefined and 2) The service is undefined.</p>
  
  <p>Here is the code in my <strong>home-cards.controller.spec.ts</strong>:</p>
  
  <pre class="lang-js prettyprint-override"><code>describe('HomeCardsController', () =&gt; {
      let homeCardsController: HomeCardsController;
      let homeCardsService: HomeCardsService;
  
      beforeEach(async () =&gt; {
          const module = await Test.createTestingModule({
              imports: [TypeOrmModule.forFeature([HomeCard])],
              controllers: [HomeCardsController],
              providers: [HomeCardsService]
          }).compile();
  
          homeCardsController = module.get&lt;HomeCardsController&gt;(HomeCardsController);
          homeCardsService = module.get&lt;HomeCardsService&gt;(HomeCardsService);
      });
  
      describe('findall', () =&gt; {
          it('should return an array of home cards', async () =&gt; {
              expect( await homeCardsController.findAll(1000)).toBeInstanceOf(Array);
          });
      });
  });
  </code></pre>
  
  <p>errors:</p>
  
  <p>New error as controller asking for user:</p>
  
  <pre><code>TypeError: Cannot read property 'clientId' of undefined
  
        17 |   async findAll(@Req() request): Promise&lt;HomeCard[]&gt; {
        18 |       const user: AuthUser = request.user;
      &gt; 19 |       return await this.homeCardsService.findAll(user.clientId);
           |                                                       ^
        20 |   }
        21 | 
        22 |   @Get(":id")
  </code></pre>