-
Notifications
You must be signed in to change notification settings - Fork 47
/
test.sh
executable file
·127 lines (101 loc) · 2.88 KB
/
test.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
122
123
124
125
126
127
#!/bin/bash
set -e
function message {
echo ""
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
echo "#" "$@"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
echo ""
}
function selenium_install {
SELENIUM_DIR="./node_modules/selenium-standalone/.selenium/"
if [ ! -d "$SELENIUM_DIR" ]; then
if [ "$CI" != true ]; then
message "Installing selenium..."
fi
npm run selenium-install
mkdir -p reports/
fi
}
function selenium_start {
# Use defult config for selenium-standalone lib
nohup npm run selenium-start > ./reports/selenium.log 2>&1&
}
function http_server_start {
SSL_CONFIG="./node_modules/webpack-dev-server/ssl/server.pem"
HTTP_SERVER="http-server ./dist_e2e --ssl --cert=${SSL_CONFIG} --key=${SSL_CONFIG}"
nohup $HTTP_SERVER > ./reports/http-server.log 2>&1&
sleep 10
}
function ci_cleanup {
rm -rf ./dist_e2e
babel-node ./test/setup/files/removeCertificate.js
rm simplefilename.testfile
}
function ci_setup {
selenium_install
node ./node_modules/phantomjs-prebuilt/install.js
npm run build:test
mv ./dist ./dist_e2e
babel-node ./test/setup/createTestInstances.js
touch simplefilename.testfile
npm run lint-tests
selenium_start
http_server_start
}
function ci_tests {
MESSAGE=$(git log --pretty=format:%s -n 1 "$CIRCLE_SHA1")
npm run lint
if [[ "$MESSAGE" == *\[e2e-skip\]* ]] || [ $CIRCLE_BRANCH = 'master' ]; then
message "[WARN] Skipping E2E tests !!!"
else
ci_setup
if [ $CIRCLE_BRANCH = 'devel' ]; then
message "Starting devel test flow..."
npm run e2e-master-devel
else
message "Starting branch test flow..."
npm run e2e-branch
fi
ci_cleanup
fi
}
function local_cleanup {
message "Closing selenium server..."
pkill -f selenium-standalone
message "Cleaning account from test instances..."
babel-node ./test/setup/deleteTestInstances.js
message "Done"
}
function local_setup {
selenium_install
message "Creating temporary instances for tests..."
babel-node ./test/setup/createTestInstances.js
touch simplefilename.testfile
message "Starting Selenium in background..."
trap local_cleanup EXIT
selenium_start
sleep 5
}
function local_tests {
local_setup
message "Checking tests with lint..."
npm run lint-tests -- --fix
if [ -n "$1" ]; then
message "Tag: ${1} local tests starts..."
npm run e2e-tag $1
else
if [[ $CI == 'local' ]]; then
message "[INFO] Running internal full tests, be sure to export all variables"
npm run e2e-branch
else
message "Full local tests starts..."
npm run e2e-local
fi
fi
}
if [ "$CI" = true ] && [ $CI != 'local' ]; then
ci_tests
else
local_tests $@
fi