The testing module only contains what you list in it. Nest can't find one of UsersService's constructor dependencies.
If the test registers the real UsersService, Nest must create it. The ? marks the position of the constructor dependency that Nest can't find. Here it is probably the repository.
Fix 1, usually the best for a controller test: don't use the real service. Provide the service token with a mock: { provide: UsersService, useValue: { findAll: jest.fn() } }. The controller receives that mock.
Fix 2, if you do want the real service: mock its dependencies instead. For example, provide a fake repository under getRepositoryToken(User).
The testing module builder also has useMocker(). It can create mocks for every missing dependency automatically.
Don't import the whole feature module when it brings TypeORM with it, because that needs a real database.
- The testing module only has what you register in it.
- The
?points to the missing constructor dependency. - For controller tests, mock the service itself.
- Or mock the service's dependencies, for example with the repository token.
useMocker()can mock missing dependencies automatically.
- Testing (https://docs.nestjs.com/fundamentals/testing)docs.nestjs.com