I was originally having this problem with create-react-app, so I did really bare bones setup just of jest:
- created new directory
- yarn init in that directory
- yarn add jest
created new file sum.js:
function sum(a, b) { return a + b; } module.exports = sum;
created file to test above function
const sum = require('./sum'); test('adds 1 + 2 = 3' , () => { expect(sum(1,2)).toBe(3); });
added to package.json:
"scripts": { "test": "jest"
},
But when I run yarn test, I get this:
terry@terry-sharewalker:~/myProjects/test-jest$ yarn jest
yarn run v1.13.0
$ /home/terry/myProjects/test-jest/node_modules/.bin/jest
and nothing happens from there. It just hangs. The same thing happened with running tests from create-react-app. react-scripts test would show, then nothing.
Here's what I got:
Jest "^24.5.0"
Ubuntu 16.04
yarn 1.13.0
watchman 4.9.0
node 10.15.3
I've reinstalled and upgraded everything I can think of, including npm, node, watchman, linuxbrew, yarn. If anybody can help me I'd be forever grateful!!