Jest: Running jest in docker with watch option throw me not supported without git/hg error

Created on 13 Feb 2018  路  11Comments  路  Source: facebook/jest

Do you want to request a _feature_ or report a _bug_?

bug

What is the current behavior?

Running with jest --watch in docker exits with --watch is not supported without git/hg, please use --watchAll error.

Running with jest --watchAll could run test successfully, however when I am trying to update snapshot with option u or o it still exits with --watch is not supported without git/hg, please use --watchAll error.

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

https://github.com/zushenyan/docker-jest-issue

What is the expected behavior?

Running Jest in Docker without errors like local machine.

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

  • docker Version 17.12.0-ce-mac49 (21995)
  • node 8.9.4-alpine
  • jest 22.2.2
  • yarn 1.3.2 (included in node:8.9.4-alpine)

Most helpful comment

I have the same problem, but my container DOES have git installed. I even installed watchman on it (built from source) but no luck

All 11 comments

I'm having this issue too, outside of docker. I am running node/jest/yarn natively in MacOS. I experience this with the -u for updating snapshot but also when performing the action described here:

https://github.com/facebook/jest/issues/5725

I use [email protected] run tests, but throw error :

TypeError: environment.setup is not a function. in node_modules/jest-cli/node_modules/jest-runner/build/run_test.js

and I use [email protected] run tests, but throw error:

node[63618] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() =>(null) (-22)

my packjson file's configure test script:

"test": "jest --env=jsdom --watch"

who can help me?

@xqlsq what does your package.json look like?

@xqlsq @SimenB is this really relevant to this issue thread?

Good point, not at all.

@xqlsq your issue is probably a mismatch in jest versions. If not, please open up a new issue if you think it's a bug in Jest. Keep in mind that this issue tracker is not a help forum

Actually it was me being silly~

Docker image node:8.9.4-alpine doesn't come with git or hg utilities.

--watch is not supported without git/hg as this error says, to get Jest work with normal watch mode you will have to install these utilities manually in your image.

For anyone puzzled by this issue please take a look at this branch for solution.

Thank you guys for answering.

I have the same problem, but my container DOES have git installed. I even installed watchman on it (built from source) but no luck

same issue as @chris-fran

I have the following on a Docker image

git version 2.11.0
node version v11.13.0
jest version 24.5.0.

Same here.
git version: 2.18.1
node version: 10.14.2
jest: 24.9.0

I used @zushenyan solution it fixed the error for --watch option but it did not reload tests.
I came up with this solution that was running jest with nodemon
cross-env NODE_ENV=test nodemon -L --exec jest

Was this page helpful?
0 / 5 - 0 ratings