Created
March 1, 2017 16:05
-
-
Save tnguyen14/66912a967b4d57dc0d1fa84d1eb07d94 to your computer and use it in GitHub Desktop.
Run functional tests inside a Selenium docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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