How can I check if a sub-component was rendered?
import { shallow } from 'enzyme'
const props = { onClick: jest.fn() }
const wrapper = <App {...props} />
const domNode = document.querySelector('#root')
const component = shallow(wrapper, domNode)
const selector = 'MySubComponent'
const subcomponent = component.find(selector)
const exists = subcomponent.exists()
expect(exists).toBe(true)
PreviousHow can I simulate a change to an input field?NextHow can I invoke a method on my component?
Last updated
Was this helpful?