Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WatchFileChange does not work when running Cypress in a WSL2 Docker container #908

Closed
sebgamby opened this issue Jun 28, 2023 · 2 comments
Closed
Assignees

Comments

@sebgamby
Copy link

Hello,

I would like to work with Cypress in interactive mode running in a WSL2 Docker container on my Windows 11 desktop. It works fine with one caveat: Cypress is incapable to detect file changes on the specs.

To give a bit of context:
I am not using a X server such as vcXsrv as it is no longer necessary with the latest WSL improvements.
My Windows build is 22621.1848
Docker Desktop is at version 4.20.1
The output of "wsl --version" is

WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.1848

I am running Cypress with this command:

docker run -it -v /run/desktop/mnt/host/wslg/.X11-unix:/tmp/.X11-unix -v /run/desktop/mnt/host/wslg:/mnt/wslg -e DISPLAY=:0 -e WAYLAND_DISPLAY=wayland-0 -e XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir -e PULSE_SERVER=/mnt/wslg/PulseServer -v .:/e2e -w /e2e --entrypoint cypress cypress/included:12.16.0 open --project .

I have tested with the default test spec created by Cypress. I have also checked in the settings that the setting watchFileChanges is set to true.

Please note that I have tested several variations to the environment presented above such as:

  • Run in a VSCode DevContainer without environment variables (e.g. DISPLAY)
  • Run in a container with environment variable DISPLAY set to host.docker.internal:0.0 and VcXsrv running

Each time, I get the same result: the Cypress window is presented, I can run the test but any modifications to the spec files is undetected and even unavailable until Cypress is restarted.

@warrensplayer
Copy link
Contributor

@sebgamby Cypress uses the node package chokidar to watch for file changes. I did a bit of research and found a potential solution described here: microsoft/WSL#4169 (comment)

Can you try adding the CHOKIDAR_USEPOLLING=true environment variable to your docker run command to see if it fixes your issue?

@sebgamby
Copy link
Author

@warrensplayer I have tried it and it works! Thanks a lot! This is going to make my life so much more simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants