-
Notifications
You must be signed in to change notification settings - Fork 157
/
cypress-run.sh
executable file
·55 lines (54 loc) · 2.65 KB
/
cypress-run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# This script handles the different ways of running Cypress across
# environments.
#
# Ideally Cypress would be run the same way everywhere, but there is
# a bug where the snapshots are generated at different sizes between
# headless and headed - https://github.com/palmerhq/cypress-image-snapshot/issues/67.
# Use the first argument as the switch "mode"
# If no argument is passed, then it defaults to "ci" mode.
case ${1} in
"local")
# Run Cypress locally with the headed browser (GUI)
CYPRESS_local=true ./node_modules/.bin/cypress open
;;
"local-update-snapshots")
# Update snapshots for the local Cypress GUI version.
# These are typically larger (see bug comment above) than the
# versions generated and used by Travis (CI) and Docker.
CYPRESS_local=true CYPRESS_updateSnapshots=true ./node_modules/.bin/cypress run --browser chrome
;;
"docker")
# Run Cypress in a headless docker image.
# This environment is closer to the Travis (CI) environment.
docker build -t videocontext-cypress-tests .
# Run with:
# --shm-size: Increased shared memory size, otherwise the tests
# sometimes hang.
# -v: Mounts the host snapshot directory, so any generated snapshots
# will be created/modified in the user's filesystem ready to be committed.
docker run -v `pwd`/test/cypress/snapshots:/cypress/test/cypress/snapshots --shm-size=256m videocontext-cypress-tests
;;
"docker-update-snapshots")
# Generate new snapshots using the headless docker image.
# These snapshots should be identical to those generated by Travis (CI)
docker build -t videocontext-cypress-tests .
# Run with:
# --shm-size: Increased shared memory size, otherwise the tests
# sometimes hang.
# -v: Mounts the host snapshot directory, so any generated snapshots
# will be created/modified in the user's filesystem ready to be committed.
docker run -v `pwd`/test/cypress/snapshots:/cypress/test/cypress/snapshots -e "CYPRESS_updateSnapshots=true" --shm-size=256m videocontext-cypress-tests
;;
*)
# Perform the command `cypress run` record the run if `CYPRESS_RECORD_KEY`
# is set this way we'll only CI will record runs and no non-robots require
# the record key.
if [ -z "$CYPRESS_RECORD_KEY" ]
then
./node_modules/.bin/cypress run --browser chrome
else
# use chrome on CI so that WebGL works
./node_modules/.bin/cypress run --record --browser chrome
fi
;;
esac