React Enzyme find second (or nth) node

后端 未结 3 1188
礼貌的吻别
礼貌的吻别 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条回答
  •  猫巷女王i
    2021-01-30 12:30

    If you are to test certain things on each one also consider iterating through the matched set:

    component.find('MyInnerComponent').forEach( (node) => {
        expect(node.prop('title')).toEqual('Good-bye')
    })
    

提交回复
热议问题