2

I am trying to use the new enzyme api for suspenseFallback introduced in enzyme 3.10.0.

Versions used:

  • enzyme-adapter-react-16: 1.14.0
  • enzyme: 3.10.0
  • react: 16.9.0
  • jest: 23.6.0

I can't get it to return my fallback or to trigger the import inside lazy.

Is there anything that I am missing?

Component under test

const VerificationComponent = ({ contract }: VerificationComponentPropsType) => {
  const Verification = lazy(() => import('./VerificationComponent'));

  return (
    <Suspense fallback={<LoadingIndicatorComponent />}>
        <Verification contract={contract} siteDefinition={getSiteDefinition()} />
    </Suspense>
  );
};

Unit test

test('should render LoadingIndicatorComponent', () => {
    const wrapper = shallow(<VerificationComponent {...VerificationComponentPropsMock} />, {
      suspenseFallback: true,
    });
    expect(wrapper.exists(LoadingIndicatorComponent)).toBeTruthy();
  });

0 Answers0