Commit befe8fdd authored by yann300's avatar yann300

nightwatch on travis using saucelabs

parent 0c85b370
language: node_js
node_js:
- stable
script: npm run test && npm run build
- stable
script:
- npm run test
- npm run build
- npm run serve &
- npm run nightwatch_local
- npm run test
deploy:
provider: script
script: ci/deploy_from_travis.sh
......
'use strict'
var TRAVIS_JOB_NUMBER = process.env.TRAVIS_JOB_NUMBER
module.exports = {
'src_folders': ['./test-browser'],
'output_folder': './test-browser/reports',
'custom_commands_path': '',
'custom_assertions_path': '',
'globals_path': '',
'page_objects_path': '',
'selenium': {
'start_process': false,
'server_path': '',
'log_path': '',
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': '',
'webdriver.ie.driver': '',
'webdriver.firefox.profile': ''
}
},
'test_settings': {
'default': {
'launch_url': 'http://ondemand.saucelabs.com:80',
'selenium_host': 'ondemand.saucelabs.com',
'selenium_port': 80,
'silent': true,
'username': 'yann300',
'access_key': 'e6f430f2-daa0-48bb-90fd-8bee20f429eb',
'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': TRAVIS_JOB_NUMBER
}
},
'local': {
'launch_url': 'http://localhost',
'selenium_host': '127.0.0.1',
'selenium_port': 4444,
'silent': true,
'screenshots': {
'enabled': false,
'path': ''
},
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true
}
},
'chrome': {
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true
}
}
}
}
{
"src_folders" : ["./test-browser"],
"output_folder" : "./test-browser/reports",
"custom_commands_path" : "",
"custom_assertions_path" : "",
"globals_path" : "",
"page_objects_path" : "",
"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"host" : "127.0.0.1",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.ie.driver" : "",
"webdriver.firefox.profile" : ""
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_host" : "127.0.0.1",
"selenium_port" : 4444,
"silent" : true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
},
"chrome" : {
"desiredCapabilities" : {
"browserName" : "firefox",
"javascriptEnabled" : true,
"acceptSslCerts" : true
}
}
}
}
......@@ -19,6 +19,7 @@
"yo-yo": "^1.2.1"
},
"devDependencies": {
"http-server": "^0.9.0",
"nightwatch": "^0.9.5",
"standard": "^7.0.1",
"standard-reporter": "^1.0.5",
......@@ -29,7 +30,8 @@
"build": "mkdir -p build; browserify src/index.js -o build/app.js",
"test": "standard && tape ./test/tests.js",
"serve": "http-server .",
"nightwatch": "nightwatch"
"nightwatch_remote": "nightwatch --config nightwatch.js --env default",
"nightwatch_local": "nightwatch --config nightwatch.js --env local"
},
"repository": {
"type": "git",
......
const https = require('https')
module.exports = function sauce (callback) {
const currentTest = this.client.currentTest
const username = this.client.options.username
const sessionId = this.client.capabilities['webdriver.remote.sessionid']
const accessKey = this.client.options.accessKey
if (!this.client.launch_url.match(/saucelabs/)) {
console.log('Not saucelabs ...')
return callback()
}
if (!username || !accessKey || !sessionId) {
console.log(this.client)
console.log('No username, accessKey or sessionId')
return callback()
}
const passed = currentTest.results.passed === currentTest.results.tests
const data = JSON.stringify({passed})
const requestPath = `/rest/v1/${username}/jobs/${sessionId}`
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)
})
res.on('end', function onEnd () {
console.info('Finished updating saucelabs')
callback()
})
}
try {
console.log('Updating saucelabs', requestPath)
const req = https.request({
hostname: 'saucelabs.com',
path: requestPath,
method: 'PUT',
auth: `${username}:${accessKey}`,
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length
}
}, responseCallback)
req.on('error', function onError (e) {
console.log('problem with request: ' + e.message)
})
req.write(data)
req.end()
} catch (error) {
console.log('Error', error)
callback()
}
}
'use strict'
var init = require('./init')
var sauce = require('./sauce')
module.exports = {
beforeEach: function (browser, done) {
init(browser, done)
try {
init(browser, done)
} catch (e) {
var mes = 'error ' + e.message
console.log(mes)
done(mes)
}
},
'Load Trace - not found': function (browser) {
......@@ -122,5 +130,7 @@ module.exports = {
.assertCallData('0x0000000000000000000000000000000000000000000000000000000000000000000000000000006060606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055')
.assertCallStack('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5\n(Contract Creation - Step 63)')
.end()
}
},
tearDown: sauce
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment