-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathrun-coverage.sh
More file actions
executable file
·51 lines (44 loc) · 1.91 KB
/
Copy pathrun-coverage.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.91 KB
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
#!/bin/bash
#
# Runs the full Selenium test suite with code-coverage collection enabled and
# renders the reports. Frontend (browser) coverage is gathered from
# Istanbul-instrumented bundles; backend (API) coverage is gathered with c8.
#
# Outputs (gitignored):
# ./coverage/frontend/report/index.html - browser/frontend coverage
# ./coverage/api/index.html - API (Node) coverage
#
set -x
# The tests run inside the containerized stack (docker-compose-run-tests.yml),
# so the browser bundles must be built with the in-container hostnames
# (api:4000 / client:3000). Using local.js here bakes http://localhost:4000
# into the bundle, which is unreachable from inside the Selenium container and
# makes every token call fail with status:0.
CONFIG_FILE=./env/docker-tests.js
CURRENT_DIR=`echo "$(dirname "$(realpath "$0")")"`
COMMON_SH=${CURRENT_DIR}/common/common.sh
if [ -r "${COMMON_SH}" ];
then
. ${COMMON_SH}
else
echo "Cannot find ${COMMON_SH}."
exit 1
fi
common_setup
export CONFIG_FILE="${CONFIG_FILE:-./env/docker-tests.js}"
COMPOSE="docker_compose -f docker-compose-run-tests.yml -f docker-compose-coverage.yml"
mkdir -p coverage/frontend/.nyc_output coverage/api
# Run the suite. Services are torn down when the tests container exits; stopping
# the API container lets c8 flush its coverage to ./coverage/api.
${COMPOSE} up --build --abort-on-container-exit --exit-code-from tests || true
# Render the frontend coverage report inside a throwaway client container, which
# has the instrumented source at the paths Istanbul recorded.
${COMPOSE} run --rm --no-deps client \
npx nyc report \
--temp-dir /coverage/frontend/.nyc_output \
--report-dir /coverage/frontend/report \
--reporter=html --reporter=lcov --reporter=text-summary || true
${COMPOSE} down
echo ""
echo "Frontend (browser) coverage: ./coverage/frontend/report/index.html"
echo "API (Node) coverage: ./coverage/api/index.html"