How to use the ioredis.mockImplementation function in ioredis

To help you get started, we’ve selected a few ioredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moleculerjs / moleculer / test / unit / transporters / redis.spec.js View on Github external
const ServiceBroker = require("../../../src/service-broker");
const Transit = require("../../../src/transit");
const RedisTransporter = require("../../../src/transporters/redis");
const P = require("../../../src/packets");

jest.mock("ioredis");

let Redis = require("ioredis");
Redis.mockImplementation(() => {
	let onCallbacks = {};
	return {
		on: jest.fn((event, cb) => onCallbacks[event] = cb),
		disconnect: jest.fn(),
		subscribe: jest.fn(),
		publish: jest.fn(),

		onCallbacks
	};
});


describe("Test RedisTransporter constructor", () => {

	it("check constructor", () => {
		let transporter = new RedisTransporter();

ioredis

A robust, performance-focused and full-featured Redis client for Node.js.

MIT
Latest version published 7 months ago

Package Health Score

88 / 100
Full package analysis