Home > Blockchain >  Nest can't resolve dependencies of the AuthService (?, JwtService)
Nest can't resolve dependencies of the AuthService (?, JwtService)

Time:03-25

I am having some problems with the test generated by default by nest js. I make sure my services are not circularly declared and are both fully exported service and imported module. I have tried other similar stack questions but it doesn't seem to be my case. Please tell me how to fix it. Thanks

here is my repository: enter image description here

enter image description here

CodePudding user response:

  • change auth.controller.spec.ts to

enter image description here

  • change auth.service.spec.ts to

enter image description here

  • change users.controller.spec.ts to

enter image description here

  • change users.service.spec.ts to

enter image description here

All your errors will be gone

enter image description here

CodePudding user response:

UsersService has a UserRepository injection. So if you want to test your controller or service that imports(or uses) UsersService, you must inject it or use repository mocking.

  • Related