How to mock a component within an Enzyme Component

Viewed 33

I am trying to set the props of a component within my shallow rendered enzyme component.

Parent.jsx

import Child from './Child';

const Parent = () => {
  return (
    <div>
      <Child disabled={true}/>
      <Child disabled={true}/>
      <Child disabled={true}/>
    </div>
  );
}

In my tests, I now want to mock this all instances of this<Child/> component with custom props e.g disabled={false}

Parent.test.jsx

 import Parent from './Parent'
 import Child from './Child'

 const wrapper = shallow(<Parent/>)

 // Set all instances of <Child/> within this wrapper to <Child disabled={false}/>

I've tried to use setProps but get ShallowWrapper::setProps() can only be called on the root.

Any idea? Thanks!

0 Answers
Related