首页 > 解决方案 > 开玩笑测试条件渲染

问题描述

我有一个包含多个子组件的组件 </ page body> ,其中一个组件道具是有条件的。当我运行测试运行时,它要求我在该行上进行测试。

**const secondCardContent = props1 && (props2 === 'something1' || props3 === 'something2') && props4 === 'something3' && (**
    <div className="product">
      <Image className="product__image" src={item.picture} alt="product__image" />
      <p className="product__name">{item.title}</p>
    </div>
  );
 
const Body = (
    <PageBody
      secondCardContent={secondCardContent}
    />

<Page>
   <PageLayout
     body={Body}
   />
</Page>

);

标签: jestjstestunit

解决方案


推荐阅读