-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
I've begun using Docker containers for many of my projects and have noticed how incredibly slow Jest runs in a Docker container when executing on a shared folder on OS X. Within Docker you can mount a local path and map it to a path within the container (e.g. ~/Source/projecta:/usr/src/app). When using this configuration my tests which consists of a single file with a single unit test takes over 30 seconds; but when run locally outside of Docker it takes 1 second. I'm using the command jest specs/unit
; which I got from another Jest issue suggesting that supplying the test folder could speed up tests, and it did, locally, from 3 seconds to 1 second; but made no change to how it runs in Docker. I would have left it at that and said that it's a Docker for Mac issue (especially because there is a speed issue with mounted volumes that is known) but I ran the same exact single test using mocha and it executed in milliseconds. The unit test is a simple expect(true).toBe(true)
(or for mocha+chai expect(true).to.equal(true)
and for some reason Jest, under Docker, executed in ~30 seconds vs mocha's less than 1 second.
Are there any configuration settings or optimizations that I could use to help speed up Jest? I would much rather use Jest over Mocha, but will obviously use the test platform that executes in a reasonable amount of time. This is my Jest configuration:
"jest": {
"automock": false,
"verbose": true,
"testFileExtensions": [
"js"
],
"moduleFileExtensions": [
"js",
"json"
],
"testDirectoryName": "spec/unit",
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/lib/"
],
"modulePathIgnorePatterns": [
"/node_modules/",
"<rootDir>/lib/"
]
}