React Enzyme find second (or nth) node

后端 未结 3 1181
礼貌的吻别
礼貌的吻别 2021-01-30 11:58

I\'m testing a React component with Jasmine Enzyme shallow rendering.

Simplified here for the purposes of this question...

function MyOuterComponent() {
         


        
3条回答
  •  鱼传尺愫
    2021-01-30 12:57

    What you want is the .at(index) method: .at(index) .

    So, for your example:

    expect(component.find('MyInnerComponent').at(1)).toHaveProp('title', 'Good-bye');

提交回复
热议问题