swsnu / swppfall2021

Learning Software Engineering By Building Web Services
28 stars 19 forks source link

Regarding mockConstructor error #93

Open chang-jin opened 3 years ago

chang-jin commented 3 years ago

Some of you have reported test fail issues which give a message like

mockConstructor(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.

The reason why you face this issue is, react-scripts version is 4.0.3 and it executes your test with the attribute, resetMocks as true by default. Therefore, your mock has been reset before executing your test spec, which causes mockConstructor error.

To fix this issue, please add this code in your package.json.

"jest": {
  "resetMocks": false
}