-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Command.setArgumentTransformer #1051
Comments
Ok. So I see now that you are supposed to support it.
In the other module using ioredis, I tried
And I am using ioredis-mock@5.2.4 |
Yeah the thing is that it's tricky to make jest module mocking work when the mock is importing something from the original. There's more alternative approaches in this thread: #568 It sounds like this approach is the most likely to succeed, but perhaps cost the most to implement, depending on how many import calls in your codebase that'll need to be updated: #568 (comment) Perhaps the best solution here is if we added another import you could use, specifically for jest:
In the |
@haakonnessjoen starting with jest.mock('ioredis', () => require('ioredis-mock/jest')); |
I am still having the same issue: Is it simply that ioredis-mock do not work with typescript at all, since ioredis is imported in the main code? |
Is that with the new |
Yes, I see it with jest.mock("ioredis", () => require("ioredis-mock/jest")); My application uses: Redis.Command.setReplyTransformer("hgetall", result => {
const arr = [];
for (let i = 0; i < result.length; i += 2) {
arr.push([String(result[i]), String(result[i + 1])]);
}
return arr;
}); During the jest run, it throws:
|
I think the issue is that > require("ioredis").Command.setReplyTransformer
[Function: setReplyTransformer] > require("ioredis-mock/jest").Command.setReplyTransformer
Uncaught TypeError: Cannot read properties of undefined (reading 'setReplyTransformer') |
The transformers implementation was never compatible with ioredis, this fixes it and also adds much-needed tests. Fixes: stipsan#1051
The transformers implementation was never compatible with ioredis, this fixes it and also adds much-needed tests. Fixes: stipsan#1051
The transformers implementation was never compatible with ioredis, this fixes it and also adds much-needed tests. Fixes: stipsan#1051
The transformers implementation was never compatible with ioredis, this fixes it and also adds much-needed tests. Also, this includes a fix for hgetall with transformers. Fixes: stipsan#1051
* fix: Fix transformers The transformers implementation was never compatible with ioredis, this fixes it and also adds much-needed tests. Also, this includes a fix for hgetall with transformers. Fixes: #1051 * Update test/command.js Co-authored-by: Cody Olsen <stipsan@gmail.com> Co-authored-by: Cody Olsen <stipsan@gmail.com>
🎉 This issue has been resolved in version 5.8.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
We are using this handy piece of code, to be able to work with hashes as objects in js:
But when using ioredis-mock, i get the following error:
So I guess that is not supported, as it works without ioredis-mock. It would be awesome to get support for that though.
The text was updated successfully, but these errors were encountered: