title: Nest can't resolve dependencies: NettJS Unit testing with TypeORM
body: <p>i have following error when try to Unit testing with NestJS.</p>
  <p>Nest can't resolve dependencies of the UsersService (UsersRepository, ?, UserRoleRepository, RoleRepository, JWTService). Please make sure that the argument CredentialsRepository at index [1] is available in the RootTestModule context.</p>
  <p>test code</p>
  <pre><code>  describe(&quot;UsersService&quot;, () =&gt; {
    let service: UsersService;
    let repositoryMock: MockType&lt;Repository&lt;Users&gt;&gt;;
    let model: typeof Users;
  
    let repo: Repository&lt;Users&gt;;
    let userController: UsersController;
    beforeEach(async () =&gt; {
      const module: TestingModule = await Test.createTestingModule({
        imports: [
          TypeOrmModule.forRoot({
            type: &quot;mysql&quot;,
            host: config.db.host,
            port: config.db.port,
            username: config.db.username,
            password: config.db.password,
            database: config.db.database,
            autoLoadEntities: true,
            synchronize: true,
          }),
          CredentialsModule,
        ],
        providers: [
          UsersService,
          CredentialsService,
          AuthService,
          JWTService,
          {
            provide: getRepositoryToken(Users),
            // useValue: {
            //   find: jest.fn(() =&gt; [Alluser]),
            // },
            useFactory: repositoryMockFactory,
          },
        ],
      }).compile();
  
      service = module.get&lt;UsersService&gt;(UsersService);
      repositoryMock = module.get(getRepositoryToken(Users));
    });
    it(&quot;User details get by Id&quot;, async () =&gt; {
      repositoryMock.findOne.mockReturnValue(testUser);
      expect(service.findUser(testUser.id)).toEqual(testUser);
      expect(repositoryMock.findOne).toHaveBeenCalledWith(testUser.id);
      // expect(await service.findOne(1)).toBeCalledWith(testUser);
    });
  
    // it(&quot;All Users details &quot;, async () =&gt; {
    //   expect(await service.find()).toEqual([Alluser]);
    // });
    // it('Create new User ', async () =&gt; {
    //   expect(await service.createNewUser(createUser)).toEqual(testUser);
    // });
  });
  </code></pre>