我有此代码:
import Icon from "./icon.svg";
it("should have a prop space", () => {
const tree = shallow(
<Button name="button test" space={Icon} />
);
expect(tree.props().space).toEqual(<span>{Icon} </span>);
});
运行它时,我将其作为答案:
期望值等于:
<span>test-file-stub </span>
已收到:
<span>test-file-stub </span>
差异: 比较值没有视觉差异。
我想念什么?
答案 0 :(得分:0)
我为预期和收到的道具写了JSON.stringify并收到了:
期望值等于: “ {\” type \“:\” span \“,\” key \“:null,\” ref \“:null,\” props \“:{\” children \“:[\” test-file-存根\”,\” \“]},\” _ owner \“:空,\” _ store \“:{}}”
收到: “ {\” type \“:\” span \“,\” key \“:null,\” ref \“:null,\” props \“:{\” children \“:[\” test-file-存根\”,\” \“,null]},\” _ owner \“:null,\” _ store \“:{}}”