Skip to content

Commit 9257552

Browse files
committed
docs: add steps for setting up X11 forwarding
1 parent 6d84c2a commit 9257552

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

docs/tests/automated-tests.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,79 @@ To run all Playwright tests locally, open a terminal outside the devcontainer an
3333
```bash
3434
docker compose run --rm playwright
3535
```
36+
37+
### Running in headed mode
38+
39+
To run Playwright in headed mode, you need to enable X11 forwarding.
40+
41+
Some steps are required for macOS and Windows to check that you have an X Server.
42+
43+
#### macOS
44+
45+
macOS doesn't provide a built-in X Server, so you'll need to install XQuartz which will provide one:
46+
47+
- Install XQuartz: `brew install --cask xquartz`
48+
- Open XQuartz, go to Preferences -> Security, and check “Allow connections from network clients”
49+
- Restart your computer (restarting XQuartz might not be enough)
50+
- Start XQuartz with `xhost +localhost`
51+
52+
#### Windows
53+
54+
Windows provides an X Server as a part of Windows Subsystem for Linux (WSL).
55+
56+
To verify that WSL and WSL GUI are installed and running:
57+
58+
- Launch WSL from the Start Menu
59+
- In the Linux terminal that opens, verify that the directory `/mnt/wslg` exists by running:
60+
61+
```bash
62+
ls -a -w 1 /mnt/wslg
63+
```
64+
65+
and that it contains these files:
66+
67+
```
68+
.
69+
..
70+
.X11-unix
71+
PulseAudioRDPSink
72+
PulseAudioRDPSource
73+
PulseServer
74+
distro
75+
doc
76+
dumps
77+
pulseaudio.log
78+
runtime-dir
79+
stderr.log
80+
versions.txt
81+
weston.log
82+
wlog.log
83+
```
84+
85+
If you don't see WSL in the Start Menu or the `ls` command fails, you need to install WSL.
86+
87+
#### Set `DISPLAY` environment variable
88+
89+
In your `.env` file, set `DISPLAY` to the value for your operating system:
90+
91+
- macOS: `host.docker.internal:0`
92+
- Linux: `$DISPLAY`
93+
- Windows: `:0`
94+
95+
For example, for macOS, you'd add this line to your `.env` file:
96+
97+
```
98+
DISPLAY=host.docker.internal:0
99+
```
100+
101+
!!! info
102+
103+
The steps above are adapted from [https://www.oddbird.net/2022/11/30/headed-playwright-in-docker/](https://www.oddbird.net/2022/11/30/headed-playwright-in-docker/).
104+
105+
#### Run all tests in headed mode
106+
107+
In `tests/playwright/pytest.ini`, add `--headed` to `addopts`, and run all tests with the same command as before:
108+
109+
```bash
110+
docker compose run --rm playwright
111+
```

0 commit comments

Comments
 (0)