Nest can't resolve dependencies of the UsersService (?). Please make sure that the argument UserRepository at index [0] is available in the RootTestModule context.
I only have one module (users) besides the AppModule. This is happening when I run the unit tests for the users controller. This is my test:
describe('UsersController', () => {
let controller: UsersController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [UsersController],
providers: [UsersService],
}).compile();
controller = module.get<UsersController>(UsersController);
});
describe('create', () => {
it('should return the created user', () => {
const createUserDto: CreateUserDto = {
username: 'test-user',
password: 'password123',
};
const result = controller.create(createUserDto);
expect(result).toBe(createUserDto);
});
});
});
I'm not sure what's wrong. The app runs fine but it errors out in tests.