React Jest Hook和Redux状态测试

时间:2020-11-12 12:54:21

标签: reactjs redux jestjs tdd enzyme

我已经尝试了很多但是被卡住了,如何使用内部reducer动作模拟选择器值。 以下未通过

it('updates the store', () => {
  console.log(component.debug());
  expect(store.dispatch).toHaveBeenCalledWith(setLastPropertyId(properties[properties.length - 1].id));
});

它给了我未定义的属性。

 const setLastProperty = () => {
if (!isEmpty(properties)) {
  dispatch(setLastPropertyId(properties[properties.length - 1].id));
}
console.log('setLastProperty -> properties', properties);

};

完整的代码是here

0 个答案:

没有答案