Jest 不运行——无限期挂起

Coc*_*oco 5 node.js jestjs ubuntu-16.04 create-react-app yarnpkg

我最初在使用 create-react-app 时遇到了这个问题,所以我只是开玩笑地做了一些简单的设置:

  1. 创建了新目录
  2. 该目录中的纱线初始化
  3. 纱线加玩笑
  4. 创建了新文件 sum.js:

       function sum(a, b) {
          return a + b;
       }
       module.exports = sum;
    
    Run Code Online (Sandbox Code Playgroud)
  5. 创建文件以测试上述功能

    const sum = require('./sum');
    
    test('adds 1 + 2 = 3' , () => {
        expect(sum(1,2)).toBe(3);
    });
    
    Run Code Online (Sandbox Code Playgroud)
  6. 添加到 package.json:

    "scripts": {
    "test": "jest"
    
    Run Code Online (Sandbox Code Playgroud)

    },

但是当我运行 yarn test 时,我得到了这个:

terry@terry-sharewalker:~/myProjects/test-jest$ yarn jest
yarn run v1.13.0
$ /home/terry/myProjects/test-jest/node_modules/.bin/jest
Run Code Online (Sandbox Code Playgroud)

从那里什么也没有发生。它只是挂起。从 create-react-app 运行测试也发生了同样的事情。react-scripts 测试会显示,然后什么都没有。

这是我得到的:

Jest "^24.5.0"
Ubuntu 16.04
yarn 1.13.0
watchman 4.9.0
node 10.15.3
Run Code Online (Sandbox Code Playgroud)

我已经重新安装并升级了我能想到的所有东西,包括 npm、node、watchman、linuxbrew、yarn。如果有人能帮助我,我将永远感激不尽!!

小智 13

我也遇到了同样的问题。可以通过更新或重新安装 watchman brew uninstall watchman&&来修复brew install watchman

更多细节可以在这里找到https://github.com/facebook/jest/issues/4529


Coc*_*oco 6

我不知道为什么这有效,但它确实有效。我在我的系统上重新安装了一些全局包:

npm update npm -g (至 6.9.0)

npm update -g  
Run Code Online (Sandbox Code Playgroud)

更新:parcel-bundler 至 1.12.3

更新的守望者:( brew update watchman 至4.9.0)


Zho*_*wen 5

在 MacOS 上卸载并重新安装 watchman 对我不起作用

我必须这样做:

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version
Run Code Online (Sandbox Code Playgroud)

https://github.com/facebook/watchman/issues/381#issuecomment-257673900