-
-
Save ryankirkman/4985246 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You need to have the following installed: | |
// https://github.com/admc/wd | |
// https://github.com/kriskowal/q | |
// https://github.com/holidayextras/node-saucelabs | |
var wd = require('wd') | |
, Q = require('q') | |
, assert = require('assert') | |
, sauce = require('saucelabs') | |
, host = "ondemand.saucelabs.com" | |
, port = 80 | |
, username = YOUR_USERNAME_GOES_HERE | |
, accessKey = YOUR_ACCESS_KEY_GOES_HERE | |
// using promisified version of webdriver | |
, browser = wd.promiseRemote(host, port, username, accessKey); | |
browser.on('status', function(info){ | |
console.log('\x1b[36m%s\x1b[0m', info); | |
}); | |
browser.on('command', function(meth, path, data){ | |
console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || ''); | |
}); | |
// general rest call helper function using promises | |
var updateJob = function (sessionID, data) { | |
var deferred = Q.defer(); | |
var myAccount = new sauce({username: username, password: accessKey}); | |
myAccount.updateJob(sessionID, data, function(err, res) { | |
deferred.resolve(res); | |
}); | |
return deferred.promise; | |
}; | |
// test case | |
browser.init({ | |
browserName: 'chrome', | |
tags: ["examples"], | |
name: "Sample QUnit test", | |
// provide build name if you want to see frontend tests | |
// summary on your jobs page | |
build: "frontend-tests-example" | |
}).then(function () { | |
return browser.get("http://saucelabs.com/test_helpers/front_tests/qunit.html") | |
.delay(3000); // wait for tests to finish | |
}).then(function () { | |
return browser.title(); | |
}).then(function (title) { | |
// are we on the right page? | |
assert.ok(~title.indexOf("Refactored date examples"), 'Wrong title!'); | |
}).then(function () { | |
// get jasmine output as JSON | |
return browser.eval("window.global_test_results"); | |
}).then(function (jsreport) { | |
// make an API call to Sauce - set custom-data with 'jasmine' data | |
var data = { | |
'custom-data': {qunit: jsreport} | |
}; | |
return updateJob(browser.sessionID, data); | |
}).then(function (body) { | |
console.log("CONGRATS - WE'RE DONE", body); | |
}).fin(function () { | |
browser.quit(); | |
}).done(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment