-
Notifications
You must be signed in to change notification settings - Fork 43
/
coverage.sh
executable file
·56 lines (44 loc) · 1.6 KB
/
coverage.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
#!/bin/bash
#
# Merges coverage reports from cypress and jest tests
# and generates an HTML report to view and json report to submit to codecov
#
set -e
case $(uname) in
Darwin)
export CODECOV_BIN="https://uploader.codecov.io/latest/macos/codecov"
;;
Linux)
export CODECOV_BIN="https://uploader.codecov.io/latest/linux/codecov"
;;
esac
rm -rf ./nyc_output
rm -rf ./coverage-jest
rm -rf ./coverage-cypress
rm -rf ./coverage
mkdir -p coverage/src
npm run test || { echo "Tests failed"; exit 1; }
cp ./coverage-jest/coverage-final.json ./coverage/src/jest.json
if [ -f cypress.config.js ]; then
npm run test:ct || { echo "Cypress tests failed"; exit 1; }
cp ./coverage-cypress/coverage-final.json ./coverage/src/cypress.json
else
echo "No cypress config found!"
fi
npx nyc merge ./coverage/src ./coverage/coverage-final.json
npx nyc report -t ./coverage --reporter html --report-dir ./coverage/html
if [ -z "${TRAVIS}" ]; then
echo "Not on travis..."
else
# Workaround for https://github.com/codecov/uploader/issues/475
unset NODE_OPTIONS
echo "Downloading codecov binary from $CODECOV_BIN"
curl -Os "$CODECOV_BIN"
chmod +x codecov
echo "Uploading to codecov"
./codecov --verbose -F "combined" -t "$CODECOV_TOKEN" -f ./coverage/coverage-final.json
./codecov --verbose -F "jest" -t "$CODECOV_TOKEN" -f ./coverage-jest/coverage-final.json
if [ -f cypress.config.js ]; then
./codecov --verbose -F "cypress" -t "$CODECOV_TOKEN" -f ./coverage-cypress/coverage-final.json
fi
fi