Skip to content

Commit 8e8b0a7

Browse files
authored
Tests: add docs to help people with the current e2e test issues (#1499)
1 parent 9fed38e commit 8e8b0a7

File tree

1 file changed

+92
-2
lines changed

1 file changed

+92
-2
lines changed

documentation/develop.md

+92-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ And start using your nodejs debugger client (like the Chrome Devtools). See http
115115
You may run the tests using one of these commands:
116116
- `yarn test` to run all the tests
117117
- `yarn test:smoke` to run the minimal test checking Grist can open, create and edit a document
118-
- `yarn test:nbrowser` to run the end-to-end tests
118+
- `yarn test:nbrowser` to run the end-to-end tests (⚠️ see warning below)
119119
- `yarn test:client` to run the tests for the client libraries
120120
- `yarn test:common` to run the tests for the common libraries shared between the client and the server
121121
- `yarn test:server` and `yarn test:gen-server` to run the backend tests depending on where the feature you would like to test resides (respectively `app/server` or `app/gen-server`)
@@ -126,9 +126,99 @@ Also some options that may interest you:
126126
- `GREP_TESTS="pattern"` in order to filter the tests to run, for example: `GREP_TESTS="Boot" yarn test:nbrowser`
127127
- `VERBOSE=1` in order to view logs when a server is spawned (especially useful to debug the end-to-end and backend tests)
128128
- `SERVER_NODE_OPTIONS="node options"` in order to pass options to the server being tested,
129-
for example: `SERVER_NODE_OPTIONS="--inspect --inspect-brk" GREP_TESTS="Boot" yarn test:nbrowser`
129+
for example: `SERVER_NODE_OPTIONS="--inspect --inspect-brk" GREP_TESTS="Boot" yarn test:nbrowser`
130130
to run the tests with the debugger (you should close the debugger each time the node process should stop)
131131

132+
## End-to-end tests
133+
134+
End-to-end tests work by simulating user mouse clicks and keyboard inputs in an actual chrome browser. By default, running `yarn test:nbrowser` opens a new browser window where automated "user" interactions happen.
135+
136+
### Headless mode
137+
138+
You can use the `MOCHA_WEBDRIVER_HEADLESS` env var to start the tests in headless mode, meaning a browser window won't be opened:
139+
140+
```
141+
MOCHA_WEBDRIVER_HEADLESS=1 yarn run test:nbrowser
142+
```
143+
144+
Running in headless mode allows you to run the tests in background, without the risk of automated tests catching window focus while you are doing something else.
145+
146+
Running in normal mode helps you understand better what happens when writing or debugging tests.
147+
148+
### Browser version issues
149+
150+
End-to-end tests are run in the GitHub CI with a specific _Chrome_ version that is known to run the tests smoothly.
151+
152+
⚠️ A current issue is that tests don't run properly with _Chrome for Testing_ binaries, or with _Chrome_ starting with version 134.
153+
154+
**If you don't have any tests randomly failing while running them locally: great! You can move on.**
155+
156+
Otherwise, you should make sure that the local test suite uses _Chrome v132_ or _Chrome v133_, and not a _Chrome for Testing_ variant.
157+
158+
In order to do that, you can use an env var to let the script know about a specific chrome binary to use. For example, if your Chrome (v132 or 133) path is `/usr/bin/google-chrome`:
159+
160+
```
161+
TEST_CHROME_BINARY_PATH="/usr/bin/google-chrome" yarn run test:nbrowser
162+
```
163+
164+
#### Using an older Chrome version than the one you have already installed
165+
166+
You might already have Chrome v134+ installed and feel stuck!
167+
168+
One solution is to build yourself a docker container matching what the GitHub actions does. Meaning, with node, python etc, an integrated Chrome v133 binary, and run tests inside that container.
169+
170+
Another solution on Linux, is to just install an old Chrome version on your system directly.
171+
172+
A simple trick is to install an old Chrome _Beta_ binary, in order to not mess with your current Chrome install.
173+
174+
#### Debian-based distro
175+
176+
You can do the same as the `buildtools/install_chrome_for_tests.sh` script, but target an old version of Chrome _Beta_ like this:
177+
178+
```bash
179+
curl -sS -o /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-beta/google-chrome-beta_133.0.6943.35-1_amd64.deb \
180+
&& sudo apt-get install --allow-downgrades -y /tmp/chrome.deb \
181+
&& rm /tmp/chrome.deb \
182+
```
183+
184+
Open `google-chrome-beta` one time manually to confirm any first-loads modals that would prevent tests to run correctly.
185+
186+
Then run tests with:
187+
188+
```
189+
SE_BROWSER_VERSION=133.0.6943.35 \
190+
SE_DRIVER_VERSION=133.0.6943.141 \
191+
TEST_CHROME_BINARY_PATH="/usr/bin/google-chrome-beta" \
192+
yarn run test:nbrowser
193+
```
194+
195+
#### Archlinux
196+
197+
Download the google-chrome-beta aur tarball matching the needed version and manually install it:
198+
199+
- download and extract [this aur tarball](https://aur.archlinux.org/cgit/aur.git/snapshot/aur-56ac6350a4f727c76f7e0c406233e7cad0a45b5f.tar.gz) (matching Chrome Beta [v133](https://aur.archlinux.org/cgit/aur.git/commit/PKGBUILD?h=google-chrome-beta&id=56ac6350a4f727c76f7e0c406233e7cad0a45b5f))
200+
- `cd` in the extracted directory and `makepkg -si`.
201+
202+
Open `google-chrome-beta` one time manually to confirm any first-loads modals that would prevent tests to run correctly.
203+
204+
Then run tests with:
205+
206+
```
207+
SE_BROWSER_VERSION=133.0.6943.35 \
208+
SE_DRIVER_VERSION=133.0.6943.141 \
209+
TEST_CHROME_BINARY_PATH="/usr/bin/google-chrome-beta" \
210+
yarn run test:nbrowser
211+
```
212+
213+
#### macOS
214+
215+
Unfortunately there is no easy way in macOS to pin Chrome version without it auto-updating. If you absolutely need to run tests locally for now:
216+
217+
- create a docker image matching the GitHub CI environment in order to run the tests inside a Linux environment having a pinned Chrome version
218+
- or… help us fix the tests (sorry)!
219+
220+
Note that tests are always run against pull requests and you can also rely on the GitHub CI instead.
221+
132222
## Develop widgets
133223

134224
Check out this repository: https://github.com/gristlabs/grist-widget#readme

0 commit comments

Comments
 (0)