笑话不运行-无限期挂起 [英] Jest doesn't run -- hangs indefinitely

查看:132
本文介绍了笑话不运行-无限期挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我本来在create-react-app上遇到这个问题,所以我真的只是开玩笑地做了一个简单的设置:

I was originally having this problem with create-react-app, so I did really bare bones setup just of jest:

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

  1. created new directory
  2. yarn init in that directory
  3. yarn add jest
  4. 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);
    });
    

  • 添加到package.json:

  • 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
    

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

    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.

    这就是我得到的:

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

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

    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!!

    推荐答案

    我不确定为什么这样做,但确实如此.我在系统上重新安装了一些全局软件包:

    I'm not sure WHY this worked, but it did. I reinstalled some global packages on my system:

    npm update npm -g(至6.9.0)

    npm update -g  
    

    此更新: 包裹捆绑至1.12.3

    this updated: parcel-bundler to 1.12.3

    更新的值班员: brew update watchman(至4.9.0)

    updated watchman: brew update watchman (to 4.9.0)

    这篇关于笑话不运行-无限期挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆