How to test style for a React component attribute with Enzyme

前端 未结 10 1001
刺人心
刺人心 2020-12-09 07:21

I am trying to test a style attribute for a React component. What is the best way to get style params in the test?

At this moment, my best option is to test if the H

10条回答
  •  半阙折子戏
    2020-12-09 08:02

    You can use this method. It returns ReactElement.

    let containerStyle = container.get(0).style;
    expect(containerStyle).to.have.property('opacity', '1');
    

提交回复
热议问题