是否有办法通过show获取Child组件的Enzyme props?
show
Child
Enzyme
const [show] = useState(true) <Parent> <Child show={show} /> </Parent>
Parent和Child都是功能组件
Parent
可能可以使用dive和props。
假设您在App组件中包含这些组件。
App
// We create a shallow render of the component // that holds `const [show] = useState(true)` and renders `<Parent> ... </Parent>` const wrapper = shallow(<App />); expect( wrapper .find(Parent) .dive() .find(Child) .dive() .props().show ).to.equal(true);