docs.nestjs.com
docs.nestjs.com copied to clipboard
How to mock/stub/change CacheModule.store option for a test app ?
I'm submitting a...
[ ] Regression
[ ] Bug report
[ ] Feature request
[ x ] Documentation issue or request (new chapter/page)
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
I didn't find any documentation how to write tests for CacheModule or change store option
Expected behavior
For example, we are using CacheModule with Redis in production. In the test app, we want to use CacheModule with memory.
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
For Tooling issues:
- Node version: any
- Platform: any
- NestJS: 6.7.1
.overrideProvider(CACHE_MODULE_OPTIONS) // exported from @nestjs/common
.useValue(newCacheModuleOptions)
might help you.
@micalevisk on nest info as this [Nest CLI] Nest CLI Version : 9.0.0
[Nest Platform Information] platform-socket.io version : 9.0.11 platform-express version : 9.0.11 mapped-types version : 1.1.0 websockets version : 9.0.11 schematics version : 9.0.1 swagger version : 6.0.5 testing version : 9.0.11 common version : 9.0.11 config version : 2.2.0 axios version : 0.1.0 core version : 9.0.11 cli version : 9.0.0
CACHE_MODULE_OPTIONS is not accessible anymore from @nestjs/common
@binarytracer that will be fixed by https://github.com/nestjs/nest/pull/10143