【发布时间】:2018-07-05 21:21:24
【问题描述】:
我正在尝试在打字稿中使用jest 和模拟ioredis。
问题是我收到来自typescript 的错误:
tests/__mocks__/ioredis.ts(5,9): error TS2339: Property 'prototype' does not exist on type 'Redis''
代码确实有效,但我想解决这个错误。 这是我的模拟:
// tests/__mocks__/ioredis.ts
import { Redis } from 'ioredis';
const IORedis: Redis = jest.genMockFromModule<Redis>('ioredis');
IORedis.prototype.hgetall = jest.fn().mockImplementation(async (key: string) => {
// Some mock implementation
});
module.exports = IORedis;
我做错了什么?
【问题讨论】:
标签: typescript jestjs