-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
playwright-docker.sh
executable file
·58 lines (47 loc) · 1.77 KB
/
playwright-docker.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
#!/bin/sh
# https://github.com/microsoft/playwright/issues/26482
# For unsupported distros, use the `test-containerized` target instead of `test`
# NOTE: this script runs a playwright server inside docker and exposes the host network to the container
# this is to expose services (such as the application you want to test) to the playwright server
docker pull mcr.microsoft.com/playwright:v1.38.0-jammy
docker ps | grep mcr.microsoft.com/playwright:v1.38.0-jammy || docker run \
-d --network="host" --add-host=host.docker.internal:host-gateway -p 9009:9009 --rm --init -it mcr.microsoft.com/playwright:v1.38.0-jammy \
/bin/sh -c "cd /home/pwuser && npx -y [email protected] run-server --port 9009"
until npx --yes wscat -c ws://localhost:9009 &1>/dev/null;
do
echo "attempting to connect to playwright server in docker"
sleep 1
done
read -p "Select the project [elements, nextjs, react, preact]: " project
read -p "Update snapshots? [y/n]: " update_snapshots
params=()
if [ "$update_snapshots" == "y" ]; then
params+=("--update-snapshots")
fi
runTest() {
echo "testing $1"
PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:9009/ npm run test -- "${params[@]}"
}
if [ "$project" != "elements" ] && [ "$project" != "nextjs" ] && [ "$project" != "react" ] && [ "$project" != "preact" ]; then
echo "Invalid project"
exit 1
fi
if [ "$project" == "elements" ]; then
echo "testing ory elements components"
runTest "elements"
exit 0
fi
if [ "$project" == "nextjs" ]; then
echo "testing nextjs app"
(cd examples/nextjs-spa && runTest "nextjs")
exit 0
fi
if [ "$project" == "react" ]; then
echo "testing react app"
(cd examples/react-spa && runTest "react")
exit 0
fi
if [ "$project" == "preact" ]; then
echo "testing preact app"
(cd examples/preact-spa && runTest "preact")
fi