I have a service that uses cache manager like so in the constructor.
constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}
app.module.ts is configured like so.
@Module({
imports: [
...
CacheModule.register(),
],
controllers: [AppController, ...],
providers: [
AppService,
...
],
})
I’ve also tried to set isGlobal: true
for the cache register but to no avail.
Terminal output on npm run test -- --runInBand
.
const retrieveFromCache = await this.cacheManager.get(textHash);
TypeError: this.cacheManager.get is not a function
I’ve tried the solutions here to get to this stage.
I suspect I’m not setting up the dependencies properly for the test to execute but not sure how to actually debug and fix that.
The code is working as expected; my trouble is with getting the tests running on methods that are using the cache service.
I went through the docs but didn’t find any section discussing on how to refactor the tests.
Any help is appreciated.