← All tasks
javascriptredis/ioredis #1308Not a task: not reproduced

Redis.Cluster can't mocked by Jest

envgap__redis__ioredis-1308

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
c14cb6c2a96f2256889da8265e6e6b49d8fd8c3f
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

redis/ioredis #1308 · read the original issue
Hello,



I struggle with an issue in my unit tests (where Jest mock the ioredis classes) with the latest v4.24.3 version.

In the previous versions the following unit tests pass:

```js

jest.mock("ioredis");



const Redis = require("ioredis");



describe("Test Redis", () => {

	it("create Redis instance", () => {

		const client = new Redis();

		expect(client).toBeInstanceOf(Redis);

		expect(Redis).toBeCalledTimes(1);

	});



	it("create Redis Cluster instance", () => {

		const client = new Redis.Cluster();

		expect(client).toBeInstanceOf(Redis.Cluster);

		expect(Redis.Cluster).toBeCalledTimes(1);

	});

});

```

**Result**

![image](https://user-images.githubusercontent.com/306521/112196360-41b76900-8c0b-11eb-9428-75c4a667476d.png)



But with v4.24.3 I've got errors for the same tests:

![image](https://user-images.githubusercontent.com/306521/112196555-71667100-8c0b-11eb-90a4-a45f025c0a7b.png)





Do you have any idea what is the problem and how can I fix it? Thanks in advance.

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]