jest hangs indefinitely, runs no tests

Abraham P picture Abraham P · Feb 17, 2018 · Viewed 12k times · Source

Every time I run jest it never runs anything. I have let the counter go arbitrarily high. I have run jest with --no-cache

jest --debug output is as follows:

{
  "configs": [
    {
      "automock": false,
      "browser": false,
      "cache": true,
      "cacheDirectory": "/var/folders/7v/64n1tsk11zs2pbwf5bm_c9kc0000gn/T/jest_dx",
      "clearMocks": false,
      "coveragePathIgnorePatterns": [
        "/node_modules/"
      ],
      "detectLeaks": false,
      "forceCoverageMatch": [],
      "globals": {},
      "haste": {
        "defaultPlatform": "ios",
        "platforms": [
          "android",
          "ios",
          "native"
        ],
        "providesModuleNodeModules": [
          "react-native"
        ]
      },
      "moduleDirectories": [
        "node_modules"
      ],
      "moduleFileExtensions": [
        "js",
        "json",
        "jsx",
        "node"
      ],
      "moduleNameMapper": [
        [
          "^React$",
          "/Users/skilurus/github/flock-react-app/node_modules/react"
        ]
      ],
      "modulePathIgnorePatterns": [
        "/Users/skilurus/github/flock-react-app/node_modules/react-native/Libraries/react-native/"
      ],
      "name": "b29a126b130a0be47202d3bc7b00f1b4",
      "resetMocks": false,
      "resetModules": false,
      "restoreMocks": false,
      "rootDir": "/Users/skilurus/github/flock-react-app",
      "roots": [
        "/Users/skilurus/github/flock-react-app"
      ],
      "runner": "jest-runner",
      "setupFiles": [
        "/Users/skilurus/github/flock-react-app/node_modules/regenerator-runtime/runtime.js",
        "/Users/skilurus/github/flock-react-app/node_modules/react-native/jest/setup.js",
        "/Users/skilurus/github/flock-react-app/test-setup.js"
      ],
      "snapshotSerializers": [
        "/Users/skilurus/github/flock-react-app/node_modules/enzyme-to-json/serializer.js"
      ],
      "testEnvironment": "/Users/skilurus/github/flock-react-app/node_modules/jest-environment-jsdom/build/index.js",
      "testEnvironmentOptions": {},
      "testLocationInResults": false,
      "testMatch": [
        "**/__tests__/**/*.js?(x)",
        "**/?(*.)(spec|test).js?(x)"
      ],
      "testPathIgnorePatterns": [
        "/node_modules/",
        "e2e"
      ],
      "testRegex": "",
      "testRunner": "/Users/skilurus/github/flock-react-app/node_modules/jest-jasmine2/build/index.js",
      "testURL": "about:blank",
      "timers": "real",
      "transform": [
        [
          "^.+\\.js$",
          "/Users/skilurus/github/flock-react-app/node_modules/babel-jest/build/index.js"
        ],
        [
          "^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$",
          "/Users/skilurus/github/flock-react-app/node_modules/react-native/jest/assetFileTransformer.js"
        ]
      ],
      "transformIgnorePatterns": [
        "node_modules/(?!react-native|native-base|react-navigation|react-native-fabric|tipsi-stripe)"
      ],
      "watchPathIgnorePatterns": []
    }
  ],
  "globalConfig": {
    "bail": false,
    "changedFilesWithAncestor": false,
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "coverageDirectory": "/Users/skilurus/github/flock-react-app/__coverage__",
    "coverageReporters": [
      "json",
      "lcov",
      "text"
    ],
    "coverageThreshold": {
      "global": {
        "branches": 70,
        "functions": 75,
        "lines": 85,
        "statements": 80
      }
    },
    "detectLeaks": false,
    "expand": false,
    "globalSetup": null,
    "globalTeardown": null,
    "listTests": false,
    "mapCoverage": false,
    "maxWorkers": 7,
    "noStackTrace": false,
    "nonFlagArgs": [],
    "notify": false,
    "notifyMode": "always",
    "passWithNoTests": false,
    "rootDir": "/Users/skilurus/github/flock-react-app",
    "runTestsByPath": false,
    "testFailureExitCode": 1,
    "testPathPattern": "",
    "testResultsProcessor": null,
    "updateSnapshot": "new",
    "useStderr": false,
    "verbose": true,
    "watch": false,
    "watchman": true
  },
  "version": "22.3.0"
}

node --version: 8.9.4

npm --version: 5.6.0

yarn --version 1.3.2

Has anybody seen anything similiar? Does anybody know hot to fix this?

Answer

rrhrg picture rrhrg · May 13, 2019

For the record, in my case it turned out to be a caching problem (I tried many many other things before).

For jest >=22.0.0 use the --clearCache option to clear the cache.

For jest <22.0.0 use the --showConfig option, search for the cacheDirectory property and delete the mentioned directory.

Hope this helps someone.