forked from openshift/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-cypress.sh
executable file
·121 lines (103 loc) · 4.41 KB
/
test-cypress.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env bash
set -euo pipefail
ARTIFACT_DIR=${ARTIFACT_DIR:=/tmp/artifacts}
SCREENSHOTS_DIR=gui_test_screenshots
# https://ci-operator-configresolver-ui-ci.apps.ci.l2s4.p1.openshiftapps.com/help#env
OPENSHIFT_CI=${OPENSHIFT_CI:=false}
if [ "$(basename "$(pwd)")" != "frontend" ]; then
echo "This script must be run from the frontend folder"
exit 1
fi
# Disable color codes in Cypress since they do not render well CI test logs.
# https://docs.cypress.io/guides/guides/continuous-integration.html#Colors
if [ "$OPENSHIFT_CI" = true ]; then
export NO_COLOR=1
fi
if [ ! -d node_modules ]; then
yarn install
fi
function copyArtifacts {
if [ -d "$ARTIFACT_DIR" ] && [ -d "$SCREENSHOTS_DIR" ]; then
echo "Copying artifacts from $(pwd)..."
cp -r "$SCREENSHOTS_DIR" "${ARTIFACT_DIR}/gui_test_screenshots"
fi
}
function generateReport {
yarn run cypress-postreport
if test -f ./packages/integration-tests-cypress/cypress-a11y-report.json; then
yarn cypress-a11y-report
fi
}
trap "copyArtifacts; generateReport" EXIT
while getopts p:s:h:l:n: flag
do
case "${flag}" in
p) pkg=${OPTARG};;
s) spec=${OPTARG};;
h) headless=${OPTARG};;
n) nightly=${OPTARG};;
esac
done
if [ $# -eq 0 ]; then
echo "Runs Cypress tests in Test Runner or headless mode"
echo "Usage: test-cypress [-p] <package> [-s] <filemask> [-h true] [-n true/false]"
echo " '-p <package>' may be 'console, 'olm', 'devconsole'"
echo " '-s <specmask>' is a file mask for spec test files, such as 'tests/monitoring/*'. Used only in headless mode when '-p' is specified."
echo " '-h true' runs Cypress in headless mode. When omitted, launches Cypress Test Runner"
echo " '-n true' runs the 'nightly' suite, all specs from selected packages in headless mode"
echo "Examples:"
echo " test-cypress.sh // displays this help text"
echo " test-cypress.sh -p console // opens Cypress Test Runner for console tests"
echo " test-cypress.sh -p olm // opens Cypress Test Runner for OLM tests"
echo " test-cypress.sh -p dev-console // opens Cypress Test Runner for Dev-Console tests"
echo " test-cypress.sh -p gitops // opens Cypress Test Runner for gitops tests"
echo " test-cypress.sh -p knative // opens Cypress Test Runner for knative tests"
echo " test-cypress.sh -p pipelines // opens Cypress Test Runner for pipelines tests"
echo " test-cypress.sh -p shipwright // opens Cypress Test Runner for shipwright tests"
echo " test-cypress.sh -p webterminal // opens Cypress Test Runner for webterminal tests"
echo " test-cypress.sh -h true // runs all packages in headless mode"
echo " test-cypress.sh -p olm -h true // runs OLM tests in headless mode"
echo " test-cypress.sh -p console -s 'tests/crud/*' -h true // runs console CRUD tests in headless mode"
echo " test-cypress.sh -n true // runs the whole nightly suite"
trap EXIT
exit;
fi
if [ -n "${nightly-}" ] && [ -z "${pkg-}" ]; then
# do not fail fast, let all suites run
set +e
err=0
trap 'err=1' ERR
yarn run test-cypress-dev-console-nightly
yarn run test-cypress-helm-nightly
yarn run test-cypress-shipwright-nightly
yarn run test-cypress-pipelines-nightly
yarn run test-cypress-topology-nightly
yarn run test-cypress-knative-nightly
# yarn run test-cypress-webterminal-nightly
exit $err;
fi
if [ -n "${headless-}" ] && [ -z "${pkg-}" ]; then
yarn run test-cypress-console-headless
yarn run test-cypress-dev-console-headless
yarn run test-cypress-olm-headless
yarn run test-cypress-helm-headless
yarn run test-cypress-knative-headless
yarn run test-cypress-topology-headless
yarn run test-cypress-pipelines-headless
yarn run test-cypress-shipwright-headless
# yarn run test-cypress-webterminal-headless
exit;
fi
yarn_script="test-cypress"
if [ -n "${pkg-}" ]; then
yarn_script="$yarn_script-$pkg"
fi
if [ -n "${nightly-}" ]; then
yarn_script="$yarn_script-nightly"
elif [ -n "${headless-}" ]; then
yarn_script="$yarn_script-headless"
fi
if [ -n "${spec-}" ] && [ -z "${nightly-}"]; then
yarn_script="$yarn_script --spec '$spec'"
fi
yarn run $yarn_script