Merge pull request #120 from yann300/tests

sauce tests
pull/1/head
chriseth 8 years ago committed by GitHub
commit 95bff0999d
  1. 10
      .travis.yml
  2. 32
      ci/browser_tests.sh
  3. 72
      ci/sauceDisconnect.js
  4. 79
      nightwatch.js
  5. 42
      nightwatch.json
  6. 11
      package.json

@ -1,17 +1,9 @@
language: node_js
node_js:
- stable
# This is disabled until we can stablize the nightwatch testing process
#before_script:
# - npm run serve &
script:
- npm run lint && npm run test && npm run build
# && nightwatch --env remote
# - pkill node
#addons:
# sauce_connect:
# username: "chriseth"
# access_key: "b781828a-9e9c-43d8-89d4-2fbb879595ca"
- ./ci/browser_tests.sh
deploy:
provider: script
script: ci/deploy_from_travis.sh

@ -0,0 +1,32 @@
#!/usr/bin/env bash
SAUCECONNECT_URL="https://saucelabs.com/downloads/sc-4.3.16-linux.tar.gz"
SAUCECONNECT_USERNAME="chriseth"
SAUCECONNECT_ACCESSKEY="b781828a-9e9c-43d8-89d4-2fbb879595ca"
SAUCECONNECT_JOBIDENTIFIER="browsersolidity_tests_${TRAVIS_JOB_NUMBER}"
SAUCECONNECT_READYFILE="sc.ready"
TEST_EXITCODE=0
npm run build
npm run serve &
wget $SAUCECONNECT_URL
tar -zxvf sc-4.3.16-linux.tar.gz
./sc-4.3.16-linux/bin/sc -u $SAUCECONNECT_USERNAME -k $SAUCECONNECT_ACCESSKEY -i $SAUCECONNECT_JOBIDENTIFIER --readyfile $SAUCECONNECT_READYFILE &
while [ ! -f $SAUCECONNECT_READYFILE ]; do
sleep .5
done
npm run browser-test-remote-firefox || TEST_EXITCODE=1
npm run browser-test-remote-chrome || TEST_EXITCODE=1
npm run browser-test-remote-safari || TEST_EXITCODE=1
npm run browser-test-remote-ie || TEST_EXITCODE=1
node ci/sauceDisconnect.js $SAUCECONNECT_USERNAME $SAUCECONNECT_ACCESSKEY $SAUCECONNECT_JOBIDENTIFIER
echo $TEST_EXITCODE
if [ $TEST_EXITCODE -eq 1 ]
then
exit 1
fi

@ -0,0 +1,72 @@
const https = require('https')
var userName = process.argv[2]
var accessKey = process.argv[3]
var tunnelName = process.argv[4]
function removeTunnel () {
const requestPath = `/rest/v1/${userName}/tunnels`
console.log(requestPath)
callSauce(requestPath, 'GET', function (error, result) {
if (error) {
console.log(error)
} else {
var data = JSON.parse(result)
for (var k in data) {
retrieveTunnel(data[k], function (error, result) {
if (error) {
console.log(error)
} else if (result.identtifier === tunnelName) {
deleteTunnel(result.id, function () {
console.log('tunnel deleted ' + data[k] + ' ' + tunnelName)
})
}
})
}
}
})
}
function retrieveTunnel (tunnelid, callback) {
const requestPath = `/rest/v1/${userName}/tunnels/${tunnelid}`
callSauce(requestPath, 'GET', function (error, result) {
if (error) {
callback(error)
} else {
callback(null, {'identtifier': JSON.parse(result).tunnel_identifier, 'id': tunnelid})
}
})
}
function deleteTunnel (tunnelid, callback) {
const requestPath = `/rest/v1/${userName}/tunnels/${tunnelid}`
callSauce(requestPath, 'DELETE', callback)
}
function callSauce (requestPath, type, callback) {
function responseCallback (res) {
res.setEncoding('utf8')
console.log('Response: ', res.statusCode, JSON.stringify(res.headers))
res.on('data', function onData (chunk) {
console.log('BODY: ' + chunk)
callback(null, chunk)
})
res.on('end', function onEnd () {})
}
var req = https.request({
hostname: 'saucelabs.com',
path: requestPath,
method: type,
auth: userName + ':' + accessKey
}, responseCallback)
req.on('error', function onError (e) {
console.log('problem with request: ' + e.message)
callback(e.message)
})
req.write('')
req.end()
}
removeTunnel()

@ -0,0 +1,79 @@
'use strict'
var TRAVIS_JOB_NUMBER = process.env.TRAVIS_JOB_NUMBER
module.exports = {
'src_folders': ['test-browser'],
'output_folder': 'reports',
'custom_commands_path': '',
'custom_assertions_path': '',
'page_objects_path': '',
'globals_path': '',
'test_settings': {
'default': {
'launch_url': 'http://ondemand.saucelabs.com:80',
'selenium_host': 'ondemand.saucelabs.com',
'selenium_port': 80,
'silent': true,
'username': 'chriseth',
'access_key': 'b781828a-9e9c-43d8-89d4-2fbb879595ca',
'use_ssl': false,
'globals': {
'waitForConditionTimeout': 10000,
'asyncHookTimeout': 100000
},
'screenshots': {
'enabled': false,
'path': ''
},
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + TRAVIS_JOB_NUMBER,
'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER
}
},
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + TRAVIS_JOB_NUMBER,
'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER
}
},
'safari': {
'desiredCapabilities': {
'browserName': 'safari',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + TRAVIS_JOB_NUMBER,
'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER
}
},
'ie': {
'desiredCapabilities': {
'browserName': 'internet explorer',
'javascriptEnabled': true,
'acceptSslCerts': true,
'build': 'build-' + TRAVIS_JOB_NUMBER,
'tunnel-identifier': 'browsersolidity_tests_' + TRAVIS_JOB_NUMBER
}
},
'local': {
'launch_url': 'http://localhost:8080',
'selenium_port': 4444,
'selenium_host': 'localhost',
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true
}
}
}
}

@ -1,42 +0,0 @@
{
"src_folders" : ["test-browser"],
"output_folder" : "reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"test_settings" : {
"default" : {
"launch_url": "http://ondemand.saucelabs.com:80",
"selenium_port": 80,
"selenium_host": "ondemand.saucelabs.com",
"silent": true,
"username": "chriseth",
"access_key": "b781828a-9e9c-43d8-89d4-2fbb879595ca",
"screenshots" : {
"enabled" : false
},
"globals": {
"waitForConditionTimeout": 60000
}
},
"remote" : {
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"local" : {
"launch_url": "http://localhost:8080",
"selenium_port": 4444,
"selenium_host": "localhost",
"desiredCapabilities": {
"browserName": "firefox",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}

@ -4,8 +4,11 @@
"description": "Minimalistic browser-based Solidity IDE",
"scripts": {
"test": "node test/index.js",
"browser-test": "nightwatch --env local",
"browser-test-sc": "nightwatch --env remote",
"browser-test": "nightwatch --config nightwatch.js --env local",
"browser-test-remote-firefox": "nightwatch --config nightwatch.js --env default",
"browser-test-remote-ie": "nightwatch --config nightwatch.js --env ie",
"browser-test-remote-chrome": "nightwatch --config nightwatch.js --env chrome",
"browser-test-remote-safari": "nightwatch --config nightwatch.js --env safari",
"build": "mkdir -p build; browserify src/index.js -o build/app.js",
"lint": "semistandard",
"serve": "http-server ."
@ -48,7 +51,9 @@
"ignore": [
"assets/js/",
"build/",
"src/mode-solidity.js"
"src/mode-solidity.js",
"nightwatch.js",
"ci/sauceDisconnect.js"
]
}
}

Loading…
Cancel
Save