我有一个看起来像这样的组件:
const MyComponent = ({ anotherComponent = null }) => {
return (
<View>
{anotherComponent}
<Text>{anotherComponent? "with anotherComponent" : "without anotherComponent"}</Text>
</View>
);
};
如何模拟AnotherComponent,以便我可以将模拟传递给MyComponent?
你能做这样的事情吗:
const anotherComponent = jest.mock("../src/AnotherComponent", () => "AnotherComponent");
,然后将anotherComponent传递给MyComponent吗?