Jest Enzyme test a React component that returns null in render method

Solution 1:

ShallowWrapper has a isEmptyRender() function:

expect(comp.isEmptyRender()).toBe(true)

Solution 2:

expect(comp.type()).toEqual(null)

That's it!

or:

expect(comp.get(0)).toBeFalsy()

Solution 3:

According to ShallowWrapper::html implementation it returns null if component instance type is null, as a result of render.

expect(comp.html()).toBeNull();

Solution 4:

we use the following with jest-enzyme

expect(comp).toBeEmptyRender()