我最初在创建反应应用程序时遇到了这个问题,所以我确实做了一个只是开玩笑的骨头:
function sum(a, b) {
return a + b;
}
module.exports = sum;
const sum = require('./sum');
test('adds 1 + 2 = 3' , () => {
expect(sum(1,2)).toBe(3);
});
"scripts": {
"test": "jest"
},但是当我进行纱线测试时,我得到了这个:
terry@terry-sharewalker:~/myProjects/test-jest$ yarn jest
yarn run v1.13.0
$ /home/terry/myProjects/test-jest/node_modules/.bin/jest
那里没有任何事情发生。它只是挂起。从create-react-app运行测试也发生了同样的事情。 react-scripts测试会显示,然后什么也没有。
这是我得到的:
Jest "^24.5.0"
Ubuntu 16.04
yarn 1.13.0
watchman 4.9.0
node 10.15.3
我重新安装并升级了我能想到的一切,包括npm,node,watchman,linuxbrew,yarn。如果有人能帮助我,我会永远感激!
我也遇到了同样的问题。可以修复更新或重新安装守望者brew uninstall watchman
和brew install watchman
。
更多细节可以在这里找到https://github.com/facebook/jest/issues/4529
我不确定为什么会这样,但确实如此。我在我的系统上重新安装了一些全局包:
npm update npm -g
(至6.9.0)
npm update -g
此更新:parcel-bundler为1.12.3
更新的守望者:brew update watchman
(至4.9.0)