Skip to content
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

RedisClient does not have connect() method implementation #211

Open
ParagWankhade opened this issue Apr 12, 2023 · 1 comment
Open

RedisClient does not have connect() method implementation #211

ParagWankhade opened this issue Apr 12, 2023 · 1 comment

Comments

@ParagWankhade
Copy link

The node-redis RedisClient module has a connect method that initates the connection. The same is missing in the mock class.

@benpbolton
Copy link

Eg. for a jest extension:

// Extend redis-mock to include isOpen, connect, and disconnect
jest.mock('redis', () => {
  const redisMock = jest.requireActual('redis-mock');
  const enhancedRedisMock = {
    ...redisMock,
    createClient: () => {
      const client = redisMock.createClient();
      client.isOpen = true;
      client.connect = jest.fn().mockResolvedValue(null);
      client.disconnect = jest.fn().mockResolvedValue(null);
      return client;
    },
  };
  return enhancedRedisMock;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants