【发布时间】:2017-12-14 21:15:50
【问题描述】:
我正在使用 Jest 模拟模块中的某些功能并以下列方式进行测试:
jest.mock("module", () => ({
funcOne: jest.fn(),
funcTwo: jest.fn(),
...
}));
import {funcOne, funcTwo, ...} from "module";
test("something when funcOne returns 'foo'", () => {
funcOne.mockImplementation(() => 'foo'); // <- Flow error
expect(...)
});
test("that same thing when funcOne returns 'bar'", () => {
funcOne.mockImplementation(() => 'bar'); // <- Flow error
expect(...)
});
如何阻止 Flow 报告 property 'mockImplementation' not found in statics of function 错误没有错误抑制(例如 $FlowFixMe)?
我了解问题出在模块中定义的函数不是 Jest-mocked 函数,并且就 Flow 而言,不包含 mockImplementation、mockReset 等方法。
【问题讨论】:
标签: javascript jestjs flowtype