DEV Community

Discussion on: The basic form for React component mocks

Collapse
 
hanvyj profile image
hanvyj

Cannot get this solution to work.

 Error: Uncaught [Error: mockConstructor(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.]
Enter fullscreen mode Exit fullscreen mode

Downgraded react-scripts to 3.4.0, installed jest-environment-jsdom-sixteen, running react-scripts test --env=jsdom-sixteen, just can't get it to run.

Collapse
 
hanvyj profile image
hanvyj • Edited

Finally! I had:

beforeEach(() => {
  jest.resetAllMocks();
});
Enter fullscreen mode Exit fullscreen mode

Which if course, was resetting the implementation. I think the issue is react-scripts 4 added "resetMocks": true, as a default so it might be fixed by just:

  "jest": {
    "resetMocks": false,
  }
Enter fullscreen mode Exit fullscreen mode

in your package.json