admin管理员组

文章数量:1431912

My jest Tests fail when running in parallel in jest.

When I try and run

jest 

From my project root I get the following error and the test process terminates.

"A worker process has quit unexpectedly!"

I am using jest 19.0.2 and node 6.9.4. I have also tried other binations of node 7.7.2 and jest 19.0 which didn't work either.

Note that when I run my tests sequentially using

jest --runInBand

My tests work fine. Although since they are not running in parallel they are slower which is not ideal.

My tests launch the same server for each new test so perhaps running parallel means that multiple tests are trying to launch the server on a port where it is already running.

Here is my package.json:

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "autoprefixer": "6.5.1",
    "babel-core": "6.17.0",
    "babel-eslint": "7.1.1",
    "babel-jest": "17.0.2",
    "babel-loader": "6.2.7",
    "babel-preset-react-app": "^2.0.1",
    "case-sensitive-paths-webpack-plugin": "1.1.4",
    "chai": "^3.5.0",
    "chai-as-promised": "^6.0.0",
    "chalk": "1.1.3",
    "connect-history-api-fallback": "1.3.0",
    "cross-spawn": "4.0.2",
    "css-loader": "0.26.0",
    "detect-port": "1.0.1",
    "dotenv": "2.0.0",
    "eslint": "3.8.1",
    "eslint-config-react-app": "^0.5.0",
    "eslint-loader": "1.6.0",
    "eslint-plugin-flowtype": "2.21.0",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.9.0",
    "filesize": "3.3.0",
    "fs-extra": "0.30.0",
    "gzip-size": "3.0.0",
    "html-webpack-plugin": "2.24.0",
    "http-proxy-middleware": "0.17.2",
    "jest": "^19.0.2",
    "jest-css-modules": "^1.1.0",
    "json-loader": "0.5.4",
    "object-assign": "4.1.0",
    "path-exists": "2.1.0",
    "postcss-loader": "1.0.0",
    "promise": "7.1.1",
    "react-dev-utils": "^0.4.2",
    "recursive-readdir": "2.1.0",
    "redux-mock-store": "^1.2.2",
    "sinon": "^1.17.7",
    "strip-ansi": "3.0.1",
    "style-loader": "0.13.1",
    "supertest": "^3.0.0",
    "url-loader": "0.5.7",
    "webpack": "1.14.0",
    "webpack-dev-server": "1.16.2",
    "webpack-manifest-plugin": "1.1.0",
    "whatwg-fetch": "1.0.0"
  },
  "dependencies": {
    "axios": "^0.15.3",
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.16.0",
    "cors": "^2.8.1",
    "eventemitter2": "^3.0.1",
    "express": "^4.14.0",
    "jwt-simple": "^0.5.1",
    "mocha": "^3.2.0",
    "mongoose": "^4.7.8",
    "morgan": "^1.7.0",
    "nodemon": "^1.11.0",
    "passport": "^0.3.2",
    "passport-jwt": "^2.2.1",
    "passport-local": "^1.0.0",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "^5.0.2",
    "react-router": "^3.0.2",
    "redux": "^3.6.0",
    "redux-devtools-extension": "^2.13.0",
    "redux-form": "^5.3.3",
    "redux-socket.io": "^1.3.1",
    "redux-thunk": "^2.2.0",
    "socket.io-client": "^1.7.3",
    "socketio-auth": "^0.1.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "jest --runInBand"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules)[/\\\\]"
    ],
    "testEnvironment": "jest-environment-jsdom",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/node_modules/jest-css-modules"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
    ],
    "verbose": true,
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    }
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}

My jest Tests fail when running in parallel in jest.

When I try and run

jest 

From my project root I get the following error and the test process terminates.

"A worker process has quit unexpectedly!"

I am using jest 19.0.2 and node 6.9.4. I have also tried other binations of node 7.7.2 and jest 19.0 which didn't work either.

Note that when I run my tests sequentially using

jest --runInBand

My tests work fine. Although since they are not running in parallel they are slower which is not ideal.

My tests launch the same server for each new test so perhaps running parallel means that multiple tests are trying to launch the server on a port where it is already running.

Here is my package.json:

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "autoprefixer": "6.5.1",
    "babel-core": "6.17.0",
    "babel-eslint": "7.1.1",
    "babel-jest": "17.0.2",
    "babel-loader": "6.2.7",
    "babel-preset-react-app": "^2.0.1",
    "case-sensitive-paths-webpack-plugin": "1.1.4",
    "chai": "^3.5.0",
    "chai-as-promised": "^6.0.0",
    "chalk": "1.1.3",
    "connect-history-api-fallback": "1.3.0",
    "cross-spawn": "4.0.2",
    "css-loader": "0.26.0",
    "detect-port": "1.0.1",
    "dotenv": "2.0.0",
    "eslint": "3.8.1",
    "eslint-config-react-app": "^0.5.0",
    "eslint-loader": "1.6.0",
    "eslint-plugin-flowtype": "2.21.0",
    "eslint-plugin-import": "2.0.1",
    "eslint-plugin-jsx-a11y": "2.2.3",
    "eslint-plugin-react": "6.4.1",
    "extract-text-webpack-plugin": "1.0.1",
    "file-loader": "0.9.0",
    "filesize": "3.3.0",
    "fs-extra": "0.30.0",
    "gzip-size": "3.0.0",
    "html-webpack-plugin": "2.24.0",
    "http-proxy-middleware": "0.17.2",
    "jest": "^19.0.2",
    "jest-css-modules": "^1.1.0",
    "json-loader": "0.5.4",
    "object-assign": "4.1.0",
    "path-exists": "2.1.0",
    "postcss-loader": "1.0.0",
    "promise": "7.1.1",
    "react-dev-utils": "^0.4.2",
    "recursive-readdir": "2.1.0",
    "redux-mock-store": "^1.2.2",
    "sinon": "^1.17.7",
    "strip-ansi": "3.0.1",
    "style-loader": "0.13.1",
    "supertest": "^3.0.0",
    "url-loader": "0.5.7",
    "webpack": "1.14.0",
    "webpack-dev-server": "1.16.2",
    "webpack-manifest-plugin": "1.1.0",
    "whatwg-fetch": "1.0.0"
  },
  "dependencies": {
    "axios": "^0.15.3",
    "bcrypt-nodejs": "0.0.3",
    "body-parser": "^1.16.0",
    "cors": "^2.8.1",
    "eventemitter2": "^3.0.1",
    "express": "^4.14.0",
    "jwt-simple": "^0.5.1",
    "mocha": "^3.2.0",
    "mongoose": "^4.7.8",
    "morgan": "^1.7.0",
    "nodemon": "^1.11.0",
    "passport": "^0.3.2",
    "passport-jwt": "^2.2.1",
    "passport-local": "^1.0.0",
    "react": "^15.4.2",
    "react-dom": "^15.4.2",
    "react-redux": "^5.0.2",
    "react-router": "^3.0.2",
    "redux": "^3.6.0",
    "redux-devtools-extension": "^2.13.0",
    "redux-form": "^5.3.3",
    "redux-socket.io": "^1.3.1",
    "redux-thunk": "^2.2.0",
    "socket.io-client": "^1.7.3",
    "socketio-auth": "^0.1.0"
  },
  "scripts": {
    "start": "node scripts/start.js",
    "build": "node scripts/build.js",
    "test": "jest --runInBand"
  },
  "jest": {
    "collectCoverageFrom": [
      "src/**/*.{js,jsx}"
    ],
    "setupFiles": [
      "<rootDir>/config/polyfills.js"
    ],
    "testPathIgnorePatterns": [
      "<rootDir>[/\\\\](build|docs|node_modules)[/\\\\]"
    ],
    "testEnvironment": "jest-environment-jsdom",
    "testURL": "http://localhost",
    "transform": {
      "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
      "^.+\\.css$": "<rootDir>/node_modules/jest-css-modules"
    },
    "transformIgnorePatterns": [
      "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
    ],
    "verbose": true,
    "moduleNameMapper": {
      "^react-native$": "react-native-web"
    }
  },
  "babel": {
    "presets": [
      "react-app"
    ]
  },
  "eslintConfig": {
    "extends": "react-app"
  }
}
Share Improve this question edited Mar 10, 2017 at 23:57 therewillbecode asked Mar 10, 2017 at 23:52 therewillbecodetherewillbecode 7,1904 gold badges37 silver badges42 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Try adding this flag to the jest CLI mand:

jest --env=jsdom --runInBand

from the Jest API docs

http://facebook.github.io/jest/docs/cli.html#env-environment

本文标签: