Accepted answer

You can use console.log(wrapper.debug()) to print an HTML-like string of the wrapper for debugging purposes. It is useful to print out to the console when tests are not passing when you expect them to.

In my case I was using export default withRouter(MyChildComponent) and it was not required to use withRouter in MyChildComponent. Removing the withRouter and Router from the MyChildComponent and MyChildComponent.test worked for me.


import {mount} from 'enzyme';
const testComponent =  mount(<TestComponent/>)

If you use shallow, it renders each component inside the TestComponent as it is, but with mount you can get all child elements inside the TestComponent.

Related Query

More Query from same tag