Open blagae opened 1 year ago
i have the same issue
Hi @blagae Thanks for reporting this issue. Redis-mock package is outdated and doesn't work properly with Node-Redis v4. We plan to provide an official mocking library for Node-redis v5. I'll post an update here once we have a preview release to test.
Please stay tuned.
Hi @uglide
Thanks for your reply. If you're still accepting and/or starting feature requests such as this for the new version, it looks like the release of v5 is not for the very near future. Is there a way that I can follow the current goals, the progress towards it, and/or some milestones ? I haven't found a comprehensive overview.
Alternatively, do you know why the node-redis library doesn't allow being used in a jest test run ? Is it something with an env variable or another type of global flag ? I wouldn't mind messing around with it a bit, including actually running a Redis server to test my code.
Any updates on this? Having similar issues with migrating to node redis v4 - a big portion of our existing tests that rely on redis-mock
fail. It would be great to get something from within the library itself, or any guidance on how to best mock the client in the new rendition of the library. Thanks!
Description
I am struggling to find a way to combine the modern Redis v4 client with the jest test framework.
This is my production code:
Some of my services of course use redis, and when I try to test them, the entire test suite usually fails at startup. This is a project that was migrated from plain JS to TS, from node-redis 3 to 4, and from mocha to jest.
Below are a few scenarios that don't work.
No config added:
Using the documented scenario with redis-mock:
in package.json
in jest.setup.redis-mock.js
Gives the error:
Messing around in the jest setup file usually ends up with the entire library being undefined, etc.