diff --git a/.travis.yml b/.travis.yml index 983cb72..b28194e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,17 @@ language: node_js +dist: xenial services: - - couchdb -sudo: false + - xvfb +sudo: true node_js: - - "5" + - "8" + script: npm run $COMMAND -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - "npm install add-cors-to-couchdb" - - "./node_modules/.bin/add-cors-to-couchdb" + env: matrix: - COMMAND=test - - CLIENT=selenium:phantomjs COMMAND=test + - CLIENT=selenium:firefox COMMAND=test - COMMAND=coverage branches: only: diff --git a/bin/run-couchdb-on-travis.sh b/bin/run-couchdb-on-travis.sh new file mode 100644 index 0000000..317ac2b --- /dev/null +++ b/bin/run-couchdb-on-travis.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +COUCH_PORT=5984 +if [ "$SERVER" = "couchdb-master" ]; then + # Install CouchDB 2.X (clustered) + docker run -d -p 5984:5984 apache/couchdb:latest --with-haproxy --with-admin-party-please -n 1 +else + # Install CouchDB 1.X + docker run -d -p 5984:5984 apache/couchdb:1 +fi + +# wait for couchdb to start, add cors +npm install add-cors-to-couchdb +while [ '200' != $(curl -s -o /dev/null -w %{http_code} http://127.0.0.1:${COUCH_PORT}) ]; do + echo waiting for couch to load... ; + sleep 1; +done +./node_modules/.bin/add-cors-to-couchdb http://127.0.0.1:${COUCH_PORT} \ No newline at end of file diff --git a/bin/run-test.sh b/bin/run-test.sh index 2a59ba8..8e9249a 100755 --- a/bin/run-test.sh +++ b/bin/run-test.sh @@ -1,5 +1,24 @@ #!/bin/bash +export COUCH_HOST='http://127.0.0.1:5984' + +if [ ! -z $TRAVIS ]; then + source ./bin/run-couchdb-on-travis.sh +fi + +printf 'Waiting for host to start .' +WAITING=0 +until $(curl --output /dev/null --silent --head --fail --max-time 2 $COUCH_HOST); do + if [ $WAITING -eq 4 ]; then + printf '\nHost failed to start\n' + exit 1 + fi + let WAITING=WAITING+1 + printf '.' + sleep 5 +done +printf '\nHost started :)' + : ${CLIENT:="node"} if [ "$CLIENT" == "node" ]; then diff --git a/bin/test-browser.js b/bin/test-browser.js index 67cbd2a..29c6c2b 100755 --- a/bin/test-browser.js +++ b/bin/test-browser.js @@ -12,6 +12,7 @@ var testTimeout = 30 * 60 * 1000; var username = process.env.SAUCE_USERNAME; var accessKey = process.env.SAUCE_ACCESS_KEY; +var SELENIUM_VERSION = process.env.SELENIUM_VERSION || '3.141.0'; // process.env.CLIENT is a colon seperated list of // (saucelabs|selenium):browserName:browserVerion:platform @@ -46,9 +47,9 @@ testUrl += '?'; testUrl += querystring.stringify(qs); if (process.env.TRAVIS && - client.browser !== 'firefox' && - client.browser !== 'phantomjs' && - process.env.TRAVIS_SECURE_ENV_VARS === 'false') { + client.browser !== 'firefox' && + client.browser !== 'phantomjs' && + process.env.TRAVIS_SECURE_ENV_VARS === 'false') { console.error('Not running test, cannot connect to saucelabs'); process.exit(1); return; @@ -81,13 +82,13 @@ function testComplete(result) { function startSelenium(callback) { // Start selenium - var opts = {version: '2.42.0'}; - selenium.install(opts, function(err) { + var opts = { version: SELENIUM_VERSION }; + selenium.install(opts, function (err) { if (err) { console.error('Failed to install selenium'); process.exit(1); } - selenium.start(opts, function(err, server) { + selenium.start(opts, function (err, server) { sauceClient = wd.promiseChainRemote(); callback(); }); diff --git a/package.json b/package.json index 5fb1d5a..a780ec4 100644 --- a/package.json +++ b/package.json @@ -35,18 +35,18 @@ "argsarray": "0.0.1", "es3ify": "^0.2.2", "inherits": "~2.0.3", - "lie": "^3.1.1", + "lie": "^3.3.0", "pouchdb-extend": "^0.1.2", - "pouchdb-promise": "^6.4.2", + "pouchdb-promise": "^6.4.3", "uniq": "^1.0.1" }, "peerDependencies": { - "pouchdb-find": "^6.4.2" + "pouchdb-find": "^7.0.0" }, "devDependencies": { "blob-util": "^1.3.0", - "bluebird": "^3.5.1", - "browserify": "^15.0.0", + "bluebird": "^3.5.4", + "browserify": "^15.2.0", "chai": "~3.5.0", "chai-as-promised": "~5.3.0", "http-server": "~0.10.0", @@ -54,14 +54,14 @@ "jshint": "2.9.5", "mocha": "~4.1.0", "phantomjs-prebuilt": "^2.1.16", - "pouchdb-find": "^6.4.2", + "pouchdb-find": "^7.0.0", "pouchdb-memory": "^6.0.0", - "request": "^2.83.0", - "sauce-connect-launcher": "^1.2.3", - "selenium-standalone": "6.12.0", - "uglify-js": "^3.3.5", + "request": "^2.88.0", + "sauce-connect-launcher": "1.2.6", + "selenium-standalone": "6.16.0", + "uglify-js": "^3.5.6", "watchify": "~3.9.0", - "wd": "^1.5.0", + "wd": "1.11.2", "mkdirp": "^0.5.1" }, "files": [