-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_e2e_tests.sh
executable file
·75 lines (66 loc) · 2.28 KB
/
run_e2e_tests.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
#!/bin/bash
# Initialize variables
target=""
target_url=""
is_headless=false # Default is false (not headless)
is_load_test=false # Default is false (not load test)
requirements_file="test_frontend/requirements.txt"
pytest_config_file="test_frontend/pytest.ini"
# Function to parse arguments for flexibility
parse_args() {
for arg in "$@"
do
case $arg in
target=*)
target="${arg#*=}"
shift # Remove once we have processed it
;;
target_url=*)
target_url="${arg#*=}"
shift # Remove once we have processed it
;;
--is-headless)
is_headless="true"
shift # Remove once we have processed it
;;
--is-load-test)
is_load_test="true"
shift # Remove once we have processed it
;;
*)
# Assume it's the target_url if target is already set
if [ -n "$target" ] && [ -z "$target_url" ]; then
target_url="$arg"
elif [ -z "$target" ]; then
target="$arg"
fi
shift
;;
esac
done
}
# Parse the input arguments
parse_args "$@"
# Activate python virtual environment
source .venv/bin/activate
# Update requirements file and pytest configuration file if it's a load test
if [ "$is_load_test" = "true" ]; then
requirements_file="test_frontend_load/requirements.txt"
pytest_config_file="test_frontend_load/pytest.ini"
fi
# Install python dependencies from the chosen requirements file
pip install -r $requirements_file
if [ -z "$target_url" ]; then
echo "Error: No target URL specified."
exit 1
fi
# Conditionally set configuration and run tests
if [ "$is_load_test" = "true" ]; then
# load testing with Playwright and pytest
PWDEBUG=0 BASE_FRONTEND_TESTING_URL="$target_url" TEST_HEADLESS="$is_headless" pytest -c $pytest_config_file "test_frontend_load/$target"
else
# Normal end-to-end testing with Playwright and pytest
PWDEBUG=0 BASE_FRONTEND_TESTING_URL="$target_url" TEST_HEADLESS="$is_headless" pytest -c $pytest_config_file "test_frontend/$target"
fi
# Deactivate python virtual environment
deactivate