I am using enzyme with jest and trying to print out wrapper.debug but I am not getting output as shown in jest docs. what is wrong here? my test file:
import React from 'react';
import Enzyme, {shallow} from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-16';
import App from './../../components/App/App';
Enzyme.configure({ adapter : new EnzymeAdapter() });
it('should render without crashing', () => {
const wrapper = shallow(<App />)
console.log(wrapper.debug());
});
my console output is this :
PASS src/test/integration/App.test.js
● Console
console.log src/test/integration/App.test.js:14
<ContextConsumer>
[function bound renderWrappedComponent]
</ContextConsumer>
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 2.8s
Ran all test suites related to changed files.
The shallow rendering is useful to test a component as a unit so it won't dive and look for your component within <ContextConsumer>.
Some options:
<ContextConsumer>..dive() which shallow render the one non-DOM child of the current wrapper. DocIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With