Jest - how to test if a component does not exist?

后端 未结 5 2001
离开以前
离开以前 2021-02-04 23:15

How do I check if a component is not present, i.e. that a specific component has not been rendered?

5条回答
  •  鱼传尺愫
    2021-02-05 00:00

    .contains receives a React Node or array of Nodes as an argument. Instead, use .find:

    expect(wrapper.find('selector').exists()).toBeTruthy()
    

提交回复
热议问题