Relative Content

Tag Archive for nestjs

`forwardRef` does not work for modules created by `Test` factory from `@nestjs/testing`

I have got an issue that I met in your GitHub issues.
I can not create a testing module Test.createTestingModule for testing that uses circular dependency.
Here https://github.com/nestjs/nest/issues/4688 I read the reason why it is a bad idea and why we should avoid it.
The main point is that it is a unity test, and we should not use forwardRef we need to build a test bad and mock. The author of the issue described that he needed it for e2e tests. I like to write tests in an integration style like e2e does and check and develop the real functionality. I also need to support forwardRef. For me, it looks like createTestingModule does not support forwardRef wrapper. My opinion is that it has to be because it is a part of the core. I am covering this by testing a service with many convoluted dependencies. It becomes a hell to describe it. Yes, we can create a helper factory. But it is also a problem to support it. I am looking for an elegant solution. I would like to do it without code refactoring. But for now, it is impossible.
Regards.

Can’t resolve Cache even though the module is being globally imported

I’m using NestJS 10.0.0, with @nestjs/cache-manager=2.2.2 and cache-manager=5.5.2 and cache-manager-redis-yet=5.0.0. However, as the title says, I’m encountering an issue where I can’t make it instantiate inside any service, even though I’ve set global parameter for CacheModule.

How to modify multiple outbound/external HTTP requests for NestJS

I have a NestJS app that acts as a central point for communicating with several different APIs. Each one will require different token authentication in the headers, so I want to have a custom HttpService for each one depending on which API I need to interact with.

How to inject a provider in NestJS from one module to another provider?

I am exporting TicketRepository from TicketModule which is then re-exported in ModelsModule from @common/models library. The TicketAccessGuard has to have a TicketRepository injected into it. I am using a factory patterns in the IncidentManagementModule to create the TicketAccessGuard because @common/models library is accessible here. Then I export the TokenAccessGuard. I import the IncidentManagementModule into the app module and use the guard (app module is not allowed to import models module).