【发布时间】:2016-08-30 18:01:47
【问题描述】:
使用 Jest 对我的反应组件进行单元测试。
我在src/components/index.js 下列出了我的组件,因此我可以执行以下操作:
import { MyComponent } from 'components';
在使用 jest 时,如何在这样的 require 路径上调用 unmock?
jest.unmock('components/MyComponent'); // ???
import { MyComponent } from 'components';
// ... tests below ...
上述方法不起作用,尽管这基本上是预期的结果。
【问题讨论】:
-
尝试使用
unmockedModulePathPatterns? -
是的。没有运气。
标签: javascript testing reactjs ecmascript-6 jestjs