I have MonoRepo project (using Lerna ) which consists of multiple packages, and one of them is a React application.
Within the React project package, I utilise Jest for unit testing. However, when I run the jest --coverage
command on the WebStorm console, it returns me the following error:
zsh: command not found: jest
Strangely enough, if I use npm run test
, the test runs, and my test coverage report is generated. Here is part of my package.json
:
"scripts": {
"test": "jest --coverage",
// other stuff
},
As you can see, npm run test
runs jest --coverage
, which is the exact command I initially entered. Why won't the jest
command work on its own?
You need to run it directly from your node_modules
like this:
./node_modules/.bin/jest --coverage
See https://jestjs.io/docs/en/getting-started#running-from-command-line for more information
最直接的解决方案是全局安装 jest:
npm i -g jest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.