This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
e2etests
executable file
·58 lines (55 loc) · 1.98 KB
/
e2etests
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
#!/bin/bash
# We change our working directory to the same location as this script is
# found so that yarn can work with the package.json file found in the same
# directory.
cd $(dirname ${0})
# Make sure the yarn environment is all up-to-date, or perform the
# install ahead of actually running the tests.
printf -- "Running \"yarn install\" command ...\n"
yarn install --network-timeout 1000000
if [[ ${?} -ne 0 ]]; then
echo "yarn install failed!" >&2
exit 1
fi
printf -- "... done running \"yarn install\" command.\n"
printf -- "NODE_ENV=%s\n" "${NODE_ENV}"
printf -- "Running \"yarn start\" command in the background...\n"
yarn start:mock &
yarn_start_pid=${!}
if [[ -z "${yarn_start_pid}" ]]; then
printf -- "yarn e2e tests failed! (could not execute \"yarn start:mock\" in background)\n" >&2
exit 1
fi
# Wait checking once a second for the web server to show up on port
# 8000 at the expected URL because the E2E tests can't start running
# until the web server is up and running.
curl_cmd="curl --output /dev/null --head --silent --fail"
while true; do
sleep 1
if ${curl_cmd} "http://localhost:8000/dashboard/"; then
break
fi
done
# Use curl to fetch the contents of the dashboard and display it to
# stdout to debugging when something goes wrong with the E2E tests.
curl -X GET http://localhost:8000/dashboard/
res=${?}
if [[ ${res} -eq 0 ]]; then
printf -- "... \"yarn start:mock\" web server up and running.\n"
# Now that the web server is running in the background, we can run
# the E2E tests which drive a headless browser against our server.
printf -- "Running E2E tests ...\n"
yarn test:e2e
res=${?}
printf -- "... E2E tests finished (%s).\n" ${res}
else
printf -- "... \"yarn start:mock\" failed to start web server (%s).\n" ${res}
fi
# The yarn start process leaves many processes lying around unless we
# explicitly kill them.
kill -s TERM -- ${yarn_start_pid}
wait
if [[ ${res} -ne 0 ]]; then
echo "yarn e2e tests failed!" >&2
fi
exit ${res}