I have built a web project with the following file structure:
-root_folder/
-docker-compose.yml
-.git/
-backend/
-.dockerignore
-docker/
-dev.dockerfile
-frontend/
-.dockerignore
-docker/
-dev.dockerfile
I run the frontend app (Angular) in a Docker container. I also run the backend app (ExpressJS) in another container but the backend is not relevant to my problem.
I have mounted the volume ./frontend to /app in the container in order to allow hot reloads.
This configuration works to run Angular just fine. However, when running Jest with the --watch flag it gives the error --watch is not supported without git/hg, please use --watchAll
I went back into the dockerfile and added:
RUN apk update -q && \
apk add -q git
But this doesn't fix the problem. From all the research I've done, it seems that the issue is that Jest watch mode uses git somehow to detect changes, but my git folder is not in the 'frontend' subdirectory.
I tried to modify my container to copy all the files to /app/frontend instead and then also copy in and mount .git folder to /app/.git but that had no effect.
I do not want to run Jest with --watchAll (but I tested it and that does run properly). Any suggestions?
EDIT Answered my own question. I was on the right track with mounting the .git folder. The missing step was setting GIT_WORK_TREE and GIT_DIR environment variables.