jest: Jest hangs on Windows Git Bash

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Running Jest within Windows Git Bash. NPM will attempt to execute Jest, but then it sits and hangs without doing anything. Here is what shows after 30 minutes of waiting:

$ npm test

> itada-web-ui@0.1.0 test C:\dev\ITADA\web-ui
> jest

What is the expected behavior? I expect the tests to run.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Environment:
 - OS: Windows 7
 - Windows Git Bash: version 2.8
 - npm: v3.7.3
 - node: v5.9.0

package.json:
...
"jest": "^18.1.0",
"babel-jest": "^18.0.0"
},
"jest": {
    "moduleDirectories": [
      "node_modules",
      "js"
    ],
    "setupFiles": [
      "<rootDir>/test/__env__/setup.js"
    ],
    "testPathIgnorePatterns": [
      "/node_modules/",
      "/js/",
      "/src/",
      "/dist/",
      "/build/",
      "/coverage/"
    ],
    "collectCoverageFrom": [
      "js/**/*.js",
      "!**/node_modules/**",
      "!**/build/**",
      "!**/dist/**",
      "!**/coverage/**"
    ],
    "coverageDirectory": "coverage",
    "coverageReporters": [
      "json",
      "lcov",
      "text-summary",
      "html"
    ]
  }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 27 (2 by maintainers)

Most upvoted comments

If you want this to be fixed, figure out why it breaks and send a pull request. This is open source, not the place where you can ask me to fix problems you are running into. I’m sorry this is unfortunate to you. If Jest doesn’t work for you, either fix it or don’t use it.

@cpojer In @bennett000 's defense this isn’t some corner-case. This is support for the windows platform at large

  • I never actually asked you to fix it.
  • I wanted to point out that there is a Windows limitation.
  • I even pointed out that it’s (mostly) irrelevant to me if you do or do not fix the issue.

I get that a lot of people demand things of OSS devs. I’m a big fan of “How to ask questions the smart way”.

Sorry for the extra stress. I’ll buy you a beer if I see you at a conference or something (not for fixing the issue just to help with your stress, as for the issue I love jest, and I’ll find a Windows machine and dig deeper)

I’ve got the same issue, using git bash, either through npm run, yarn run or directly running the jest global.

However adding the -i ‘–runInBand’ option fixes this for me, not sure why.

FYI for anyone still following, it’s not just git bash.

For me it works in cmd but doesn’t work on our build server (Bamboo). Tests just hangs without any output. I killed the process after 90 minutes (tests usually complete in about 1 minute). All other npm & node tasks seem to work fine.

--runInBand works for me in this scenario.

I have the same problem. It hangs on when executing npm test, yarn test or directly jest.

Environment:

  • OS: Windows 10 (VM)
  • Git for Windows: 2.10.0.1
  • npm: v3.8.6
  • node: v5.12.0
  • jest: 19.0.2

Config:

$ ./node_modules/.bin/cross-env BABEL_ENV=commonjs ./node_modules/.bin/jest --debug
jest version = 19.0.2
test framework = jasmine2
config = {
  "automock": false,
  "bail": false,
  "browser": false,
  "cacheDirectory": "C:\\Users\\IEUser\\AppData\\Local\\Temp\\jest",
  "clearMocks": false,
  "coveragePathIgnorePatterns": [
    "\\\\node_modules\\\\"
  ],
  "coverageReporters": [
    "json",
    "text",
    "lcov",
    "clover"
  ],
  "expand": false,
  "globals": {
    "__HOT_BUILD_DATE__": "",
    "__HOT_PACKAGE_NAME__": "",
    "__HOT_VERSION__": "",
    "__HOT_BASE_VERSION__": ""
  },
  "haste": {
    "providesModuleNodeModules": []
  },
  "moduleDirectories": [
    "node_modules"
  ],
  "moduleFileExtensions": [
    "js",
    "json",
    "jsx",
    "node"
  ],
  "moduleNameMapper": [
    [
      "^handsontable(.*)$",
      "C:\\Users\\IEUser\\handsontable\\src$1"
    ],
    [
      "^walkontable(.*)$",
      "C:\\Users\\IEUser\\handsontable\\src\\3rdparty\\walkontable\\src$1"
    ],
    [
      "\\.css$",
      "C:\\Users\\IEUser\\handsontable\\test\\__mocks__\\styleMock.js"
    ]
  ],
  "modulePathIgnorePatterns": [],
  "noStackTrace": false,
  "notify": false,
  "preset": null,
  "resetMocks": false,
  "resetModules": false,
  "roots": [
    "C:\\Users\\IEUser\\handsontable\\test\\unit",
    "C:\\Users\\IEUser\\handsontable\\src\\plugins"
  ],
  "snapshotSerializers": [],
  "testEnvironment": "jest-environment-jsdom",
  "testMatch": [],
  "testPathIgnorePatterns": [
    "C:\\\\Users\\\\IEUser\\\\handsontable\\\\node_modules\\\\",
    "C:\\\\Users\\\\IEUser\\\\handsontable\\\\test\\\\unit\\\\index.js"
  ],
  "testRegex": "(\\.spec\\.js)|(\\.unit\\.js)$",
  "testResultsProcessor": null,
  "testURL": "about:blank",
  "timers": "real",
  "transformIgnorePatterns": [
    "\\\\node_modules\\\\"
  ],
  "useStderr": false,
  "verbose": null,
  "watch": false,
  "rootDir": "C:\\Users\\IEUser\\handsontable",
  "name": "a82ab501bc3859fd81bb01d2f351c915",
  "setupFiles": [
    "C:\\Users\\IEUser\\handsontable\\node_modules\\babel-polyfill\\lib\\index.js"
  ],
  "testRunner": "C:\\Users\\IEUser\\handsontable\\node_modules\\jest-jasmine2\\build\\index.js",
  "transform": [
    [
      "^.+\\.jsx?$",
      "C:\\Users\\IEUser\\handsontable\\node_modules\\babel-jest\\build\\index.js"
    ]
  ],
  "cache": true,
  "watchman": true
}

Edit: My tests started working when it runs in the same process (with --runInBand argument)

For anyone on windows getting jest hang, make sure you are using the latest available version (at least 22.0.6). I was playing around with some 3rd party code that had a pre-commit hook with jest and it was just hanging and -i didn’t seem to help. Updating the jest dependency seems to have worked.

For the npm crowd, the fix from @sebinsua also works when adjusted like so:

alias npm='winpty npm.cmd'

(For npm test that calls jest)

We’ve moved off of Windows onto Mac. Never could get it to work on git bash for me, but others on the team could get it to run.

I don’t see much help for this issue as it appears to be limited solely to git bash. The tests ran just fine in CMD/Powershell.

update: we used -i on our team-member’s Windows machine and all is working well again.

I ran into this issue too. runInBand fixes it but is clearly suboptimal. Also using -i and --watch causes all tests to get trigger upon just a modification of a single test file. (v20.0.4)

It seems like this is not a Jest issue but rather a Windows issue? What happens if you do --no-watchman?

Same here. But it works very well with Yarn (yarn test).