Below settings for my package.json
If I run from command line npm test all jest test cases are executed properly. In case I use directly the command
npm test
I solved this issue using:
remove node_modules remove package-lock.json
node_modules
package-lock.json
remove dev dependence from package.json of jest npm remove jest --save-dev.
package.json
npm remove jest --save-dev.
npm cache clean
then run command npm install
npm install
then install npm install jest@latest --save-dev
npm install jest@latest --save-dev
this works for me