我有一個這樣的模擬模塊中的我的組件測試文件如何在每個測試中更改jest模擬函數返回值?
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();
});
這種運行測試用例我想改變模擬模塊,因爲我是函數返回值false
這樣的動態
jest.mock('../../../magic/index',() => ({
navigationEnabled:() => false,
guidanceEnabled:() => false
}));
導入RowListItem
組件已經一次,所以我的模擬模塊不會再次導入。所以它不會改變。我該如何解決這個問題?