I have a fairly simple component that renders another component, its navigation. I have test in place to test whether it has been rendered inside. I'm using Jest and Enzyme v3.
it('renders navigation', () => {
const component = mount(
<Calendar />
);
const navigation = component.find('.react-calendar__navigation');
expect(navigation.length).toBe(1);
});
Interestingly, this test passed without any issues on my computer. However, on Travis CI, I got the following error:
TypeError: Cannot read property 'rendered' of null
at Object.getNode (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:233:69)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:100:33)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous> (src/__tests__/Calendar.jsx:13:39)
at Promise (<anonymous>)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
The code worked fine on Enzyme 2.9.1. Do you have any hints on what I could be doing wrong?
My bad, for some reason React stayed at 15.6.1 causing this error.
Lol... Had the same thing happen. This issue made me check my package.json and feel shame. Quickly after the shame faded, my tests were working again though. Thanks!
Same shame.. so sad
Make sure react-dom is also @16, and that will help too. :)
Most helpful comment
My bad, for some reason React stayed at 15.6.1 causing this error.