首页 > 解决方案 > Jest 不运行 - 无限期挂起

问题描述

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

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

       function sum(a, b) {
          return a + b;
       }
       module.exports = sum;
    
  5. 创建文件来测试上述功能

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

    "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 test 会显示,然后什么也没有。

这是我得到的:

Jest "^24.5.0"
Ubuntu 16.04
yarn 1.13.0
watchman 4.9.0
node 10.15.3

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

标签: node.jsjestjsubuntu-16.04create-react-appyarnpkg

解决方案


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

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


推荐阅读