I am able to test multiple files using Jest, but I cannot figure out how to test a single file.
npm install jest-cli --save-dev
npm test app/foo/__tests__/bar.spec.js
npm ERR! Error: ENOENT, open '<path to project>/node_modules/app/foo/__tests__/bar.spec.js/package.json'
npm test works, it means jest is installed globally. In order to run a specific test, you'll need to use the
npm test will not work.
So you can run jest directly with
Note: You don't have to enter the full path of your test: the argument becomes a regexp, thus it only needs to be part of the full path.
Note 2.0: If you have used
npm install -g jest to install jest globally,
change it as
npm install -g jest-cli