forked from siemens/ngx-datatable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e-local.sh
105 lines (92 loc) · 2.15 KB
/
e2e-local.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
#!/bin/sh
cd $(dirname $0)
# this is to stop MSys (Git bash on Windows) from messing with the paths
export MSYS_NO_PATHCONV=1
# Keep image version in sync with image used in .gitlab-ci.yml
PLAYWRIGHT_IMAGE="mcr.microsoft.com/playwright:v1.46.0-jammy"
OS=$(uname -s)
CWD=$(pwd)
if [ x"$DOCKER" = "x" ]; then
DOCKER=docker
fi
case "$DOCKER" in
*podman*)
BRIDGE_ADDRESS=host.containers.internal
;;
*)
BRIDGE_ADDRESS=host.docker.internal
;;
esac
if command -v getenforce &> /dev/null && [ "$(getenforce)" = "Enforcing" ]; then
MOUNT_FLAGS=",Z"
fi
LOCAL_ADDRESS=$BRIDGE_ADDRESS
NETWORK_MODE=bridge
DISPLAY=$LOCAL_ADDRESS:0
case "$OS" in
Linux*)
LOCAL_ADDRESS=localhost
NETWORK_MODE=host
DISPLAY=$DISPLAY
;;
MINGW*)
CWD=$(cygpath -w $CWD)
;;
esac
if [ x$PORT = "x" ]; then
PORT=4200
fi
echo "Using '$DOCKER' in '$NETWORK_MODE' mode, connecting to '$LOCAL_ADDRESS:$PORT'"
if [ x$1 = "xshell" ]; then
shift
$DOCKER run -it --rm \
-e DISPLAY=$DISPLAY \
-e LOCAL_ADDRESS=$LOCAL_ADDRESS \
-e PORT=$PORT \
-e PLAYWRIGHT_CONTAINER=true \
-e PLAYWRIGHT_isvrt=true \
-e PLAYWRIGHT_staticTest=$PLAYWRIGHT_staticTest \
-v $CWD:/e2e:rw$MOUNT_FLAGS \
-w /e2e \
--net=$NETWORK_MODE \
--ipc=host \
--entrypoint bash \
$PLAYWRIGHT_IMAGE \
"$@"
else
if [ x$1 = "xrun" ]; then
shift
fi
if [ x$1 = "xvrt" ]; then
shift
PLAYWRIGHT_isvrt=true
fi
if [ x$1 = "xa11y" ]; then
shift
PLAYWRIGHT_isa11y=true
fi
if [ x$1 = "xupdate" ]; then
shift
# using env var so the user can pass a --env
UPDATE_ARGS="--update-snapshots"
PLAYWRIGHT_isvrt=true
fi
$DOCKER run -it --rm \
-e LOCAL_ADDRESS=$LOCAL_ADDRESS \
-e PORT=$PORT \
-e PLAYWRIGHT_CONTAINER=true \
-e PLAYWRIGHT_isa11y=$PLAYWRIGHT_isa11y \
-e PLAYWRIGHT_isvrt=$PLAYWRIGHT_isvrt \
-e PLAYWRIGHT_staticTest=$PLAYWRIGHT_staticTest \
-v $CWD:/e2e:rw$MOUNT_FLAGS \
-w /e2e \
--net=$NETWORK_MODE \
--ipc=host \
$PLAYWRIGHT_IMAGE \
npx \
playwright \
test \
$UPDATE_ARGS \
"$@" \
|| yarn playwright show-report playwright/results/preview
fi