我的组件测试文件中有一个这样的模拟module
jest.mock('../../../magic/index', () => ({
navigationEnabled: () => true,
guidanceEnabled: () => true
}));
这些函数将在我的组件的渲染函数中调用以隐藏和显示某些特定功能。
我想对这些模拟函数的返回值的不同组合进行快照。
因为假设我有一个这样的测试用例
it('RowListItem should not render navigation and guidance options', () => {
const wrapper = shallow(
<RowListItem type="regularList" {...props} />
);
expect(enzymeToJson(wrapper)).toMatchSnapshot();
});
我想要改变模拟module函数的返回值来运行这个测试案例false
是这样动态
jest.mock('../../../magic/index', () => ({
navigationEnabled: () => false,
guidanceEnabled: () => false
}));
因为我已经导入RowListItem
了一次组件,所以我的模拟module不会再次导入。所以它不会改变。我该如何解决这个问题?