如何使用jest / react-testing-library测试组件正在返回特定的JSX?
我必须有toBeInstanceOf,等等,但是很难找到有关“反应测试库”的信息
这些是一些例子
const classname = props.classname;
if (!props.action) {
return props.children;
}
const { id,type,target } = props.action;
if (type === "EXTERNAL") {
return (
<a classname={classname} href={target}>
{props.children}
</a>
);
}
if (["page"].includes(type.toLowerCase())) {
return (
<Link classname={classname} key={id} to={"/" + target}>
{props.children}
</Link>
);
}
if (type.toLowerCase() === "play") {
return props.children;
} ...
如您所见,每个收益都是不同的jsx。