Skip to content

Instantly share code, notes, and snippets.

Created March 1, 2017 16:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Run functional tests inside a Selenium docker container
#!/usr/bin/env bash
# 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
case "$*" in
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
npm test -- "$@" 2> /dev/null
# save exit code of subshell
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