Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run functional tests inside a Selenium docker container
#!/usr/bin/env bash
CONTAINER_NAME="docker-selenium-chrome"
# remove any pre-existing container
if [ $(docker ps -a | grep $CONTAINER_NAME | awk '{print $NF}' | wc -l) -gt 0 ]; then
docker rm -f $CONTAINER_NAME 1>/dev/null
fi
case "$*" in
*--debug*)
docker run -d -p 4444:4444 -p 5902:5900 --name $CONTAINER_NAME -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:3.1.0 1>/dev/null
sleep 2 # wait a bit for container to start
open vnc://:secret@localhost:5902
;;
*)
docker run -d -p 4444:4444 --name $CONTAINER_NAME -v /dev/shm:/dev/shm selenium/standalone-chrome:3.1.0 1>/dev/null
;;
esac
(
npm test -- "$@" 2> /dev/null
)
# save exit code of subshell
testresult=$?
docker stop $CONTAINER_NAME 1>/dev/null && docker rm $CONTAINER_NAME 1>/dev/null
exit $testresult
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.