Skip to content

Instantly share code, notes, and snippets.

@tnguyen14
Created March 1, 2017 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnguyen14/66912a967b4d57dc0d1fa84d1eb07d94 to your computer and use it in GitHub Desktop.
Save tnguyen14/66912a967b4d57dc0d1fa84d1eb07d94 to your computer and use it in GitHub Desktop.
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