-
Notifications
You must be signed in to change notification settings - Fork 1
/
cypress-mocked.sh
executable file
·64 lines (52 loc) · 1.74 KB
/
cypress-mocked.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
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Quickly fire up Cypress using the CI settings for interactive local usage.
# Set DEV_MODE=true to run the mocked tests with the development server.
# We default to false here.
: "${DEV_MODE:=false}"
if [[ "$DEV_MODE" == "true" ]]; then
echo "Opening Cypress mocked tests with development server..."
else
echo "Opening Cypress mocked tests..."
fi
if pgrep "nginx" >/dev/null
then
echo "nginx is running - ok"
else
echo "nginx is stopped, please start nginx"
exit 0
fi
set -ae
trap 'kill $(jobs -p)' INT TERM EXIT
echo "loading environment variables"
source cypress-mocked.env
CI_ENV=$(cat cypress-mocked.env | tr '\n' ',')
CI_ENV=${CI_ENV%?}
# Used to tell Gateway server we're running in Cypress
RUNNING_IN_CYPRESS=true
RUNNING_IN_CYPRESS_MOCKED=true
if [ -z ${NODE_EXTRA_CA_CERTS+x} ]; then
echo "NODE_EXTRA_CA_CERTS is unset in your bash config, see setup docs on how to set this."
echo "Setting NODE_EXTRA_CA_CERTS locally for now."
NODE_EXTRA_CA_CERTS="$(mkcert -CAROOT)/rootCA.pem"
else
echo "NODE_EXTRA_CA_CERTS is set."
fi
# In CI we build from the production config
if [[ "$DEV_MODE" == "false" ]]; then
echo "building gateway"
pnpm run build
fi
echo "starting mock server"
pnpm run mock-server &
pnpm run wait-on:mock-server
echo "starting gateway server, and waiting for https://profile.thegulocal.com/healthcheck"
# In CI we build from the start the production server
if [[ "$DEV_MODE" == "false" ]]; then
pnpm run start &
pnpm run wait-on:server
else
# In DEV we want to watch and reload the server
pnpm run watch:server & pnpm run watch & pnpm run wait-on:server
fi
echo "opening cypress"
pnpm run cypress open --env $CI_ENV --config '{"e2e":{"specPattern":["**/mocked/**/*.cy.ts"]}}' --e2e --browser chrome