This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Set up parallel continuous testing
Matti Schneider edited this page Mar 29, 2017
·
4 revisions
We will use SauceLabs and CircleCI to automate continuous integration testing with Watai. SauceLabs is free for open-source projects.
- Create a new (machine) user on GitHub.
- Give it access to the repo you want to test.
- Create a new Open Sauce account, logging in with that machine user.
- Add repo to CircleCI.
- Get your SauceLabs access token and add it as
SAUCE_ACCESS_KEY
to CircleCI through the Web UI (Circle > repo > settings > Environment variables). - Add Watai as a dependency to your project (
npm install --save-dev watai
). - Copy (or integrate if you already have one) the
circle.yml
template below to the root of the repo you want to test. - Copy the
config-ci.js
below next to your Wataiconfig.js
, in the folder that contains your integration tests.
machine:
environment:
browser_name: $(case $CIRCLE_NODE_INDEX in 0) browser='chrome' ;; 1) browser='firefox' ;; 2) browser='internet explorer' ;; 3) browser='iphone' ;; esac; echo $browser)
browser_version: $(case $CIRCLE_NODE_INDEX in 3) version='8.2' ;; esac; echo $version)
SAUCE_LOG: $CIRCLE_ARTIFACTS/sauce_log.txt
WATAI_TESTS: test/integration
SAUCE_USERNAME: my-bot
# SAUCE_ACCESS_KEY is defined in the CircleCI web UI
dependencies:
post:
- npm install saucelabs@0.1.1 # allow sending Watai results to SauceLabs; version lock needed due to https://github.com/danjenkins/node-saucelabs/pull/21
- wget https://saucelabs.com/downloads/sc-latest-linux.tar.gz
- tar -xzf sc-latest-linux.tar.gz
test:
pre:
# start server
- npm start:
background: true
parallel: true
# start Sauce Connect
- cd sc-*-linux && ./bin/sc --user $SAUCE_USERNAME --api-key $SAUCE_ACCESS_KEY --tunnel-identifier "circle-$CIRCLE_BUILD_NUM-$CIRCLE_NODE_INDEX" --readyfile ~/sauce_is_ready > $SAUCE_LOG:
background: true
parallel: true
# wait for Sauce Connect
- while [ ! -e ~/sauce_is_ready ]; do sleep 1; done:
parallel: true
# wait for server (after Sauce Connect because it is faster to start)
- wget --retry-connrefused --waitretry=1 --output-document=/dev/null http://localhost:$PORT:
parallel: true
# prepare CI-specific config holder and add CI-specific config to Watai
- mkdir $HOME/.watai && cp $WATAI_TESTS/config-ci.js $HOME/.watai/config.js:
parallel: true
override:
- watai $WATAI_TESTS --config '{"driverCapabilities":{"browserName":"'"$browser_name"'","version":"'"$browser_version"'"}}':
parallel: true
post:
- killall --wait sc: # wait until Sauce Connect closes the tunnel
parallel: true
// this file is for use in CircleCI continuous integration environment
module.exports = {
seleniumServerURL: {
hostname : 'ondemand.saucelabs.com',
port : 80,
},
driverCapabilities: {
platform : 'Windows 7',
'tunnel-identifier' : 'circle-' + process.env.CIRCLE_BUILD_NUM + '-' + process.env.CIRCLE_NODE_INDEX,
},
tags : [ 'circle-ci', '#' + process.env.CIRCLE_BUILD_NUM ],
views : [ 'Verbose', 'SauceLabs' ],
quit : 'always', // avoid wasting 90 seconds on SauceLabs
bail : true,
build : 'CircleCI#' + process.env.CIRCLE_BUILD_NUM,
}