Jest: Super slow when running in Jest Travis-CI(any CI for that matter)

Created on 19 Jun 2017  路  6Comments  路  Source: facebook/jest

I'm having a feeling its related to the number of workers and the hardware that the CI provider runs on, but I was curious if anyone has any nice recipes for Travis-CI?

It takes a solid 8 mins to run a coverage task.

Here is my jest configuration:

"jest": {
    "testRegex": ".*?(\\.spec).js",
    "transformIgnorePatterns": [
      "node_modules"
    ],
    "collectCoverageFrom": [
      "client/**/*.js",
      "client/**/*.jsx",
      "server/**/*.js*"
    ],
    "transform": {
      ".*": "<rootDir>/node_modules/babel-jest/build/index.js"
    },
    "setupFiles": [
      "./utilities/testSetup.js"
    ],
    "moduleNameMapper": {
      "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/utilities/fileMock.js",
      "\\.(css|less)$": "identity-obj-proxy"
    },
    "coverageReporters": [
      "json",
      "html",
      "text",
      "lcov",
      "clover"
    ]
  }

My run commands:

    "test": "jest --silent",
    "test:watch": "npm run test -- --watch",
    "test:coverage": "jest --coverage",

Most helpful comment

http://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server
tl;dr use jest --runInBand or jest --maxWorkers=4 or something, it depends on CI.

All 6 comments

http://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server
tl;dr use jest --runInBand or jest --maxWorkers=4 or something, it depends on CI.

@thymikee jest --maxWorkers=4 worked like a charm, did it right before you sent the response.

Awesome! Can you make a PR with a note about that on Travis CI --maxWorkers=4 usually works good?

Could be worth. building that into Jest - Travis is a super popular CI? (you can look for the ENV var "HAS_JOSH_K_SEAL_OF_APPROVAL" and assume it's travis )

@thymikee Yep I'll put together a PR today in the docs, thanks!

For future Google visitors, you can find more knowledge on in this --maxWorkers on that blog post

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Secretmapper picture Secretmapper  路  3Comments

mmcgahan picture mmcgahan  路  3Comments

paularmstrong picture paularmstrong  路  3Comments

samzhang111 picture samzhang111  路  3Comments

gustavjf picture gustavjf  路  3Comments