【发布时间】:2019-12-30 23:56:05
【问题描述】:
如何使用 Jest 和 Enzyme 测试此功能?
addProducts = id => {
toast.success("Product added", {
position: toast.POSITION.TOP_RIGHT
});
history.push(`/product/${id}`);
};
我正在使用这个 sn-p 的代码,但它还不够......
it("Must return added addProduct with success message", () => {
const componente = shallow(<AddProduct />);
const spy = jest.spyOn(wrapper.instance(), "addProducts");
expect(spy).toBeTruthy();
});
【问题讨论】: