Allows you to run your unit tests through Sauce Labs API without Grunt.
If you want to add your project here do not hesitate to open a PR 😉
npm install jsunitsaucelabs --save-dev
JSUnitSaucelabs constructor accepts the following parameters (the following are the default values):
{
username: null,
password: null,
tunneled: true,
build: null,
verbose: false,
verboseMode: null, // accept : "debug", "info", "warn"
hostname: 'saucelabs.com',
base: '/rest/v1/'
}
This method allows you to initialise a tunnel between you and Sauce Labs, when this tunnel is started,
JSUnitSaucelabs will emit tunnelCreated
event
JSUnitSaucelabs inherit from
EventEmitter
This method uses :username/js-tests
from Sauce Labs API.
See here.
-
platforms
: Array of platforms -
url
: should point to the page that hosts your tests -
framework
: the framework used for your tests (QUnit, Jasmine, ...) -
callback
: function to handle error or successcallback(error, result)
If you use a tunnel between Sauce Labs and you, you shouldn't call start before the connection is established (see
initTunnel
method)
This method uses :username/js-tests/status
from Sauce Labs API.
See here.
-
taskIds
: Array of task IDs returned by Sauce Labs API -
callback
: function to handle error or successcallback(error, result)
Allows you to stop the tunnel between you and Sauce Labs
var JSUnitSaucelabs = require('jsunitsaucelabs')
var jsUnitSaucelabs = new JSUnitSaucelabs({
username: 'your-saucelabs-username',
password: 'your-saucelabs-api-key'
})
var testURL = 'http://localhost/index.html?hidepassed'
jsUnitSaucelabs.on('tunnelCreated', function () {
jsUnitSaucelabs.start([
['Windows 8', 'internet explorer', '10']/*,
['OS X 10.8', 'safari', '6']*/
], testURL, 'qunit', function (error, success) {
if (typeof success !== undefined) {
var taskIds = success['js tests']
if (!taskIds || !taskIds.length) {
throw new Error('Error starting tests through Sauce Labs API')
}
var waitingCallback = function (error, success) {
if (error) {
console.error(error)
return
}
if (typeof success !== 'undefined') {
if (!success.completed) {
jsUnitSaucelabs.getStatus(taskIds[0], waitingCallback)
} else {
var test = success['js tests'][0]
var passed = false
if (test.result !== null) {
passed = test.result.total === test.result.passed
}
console.log('Tested ' + testURL)
console.log('Platform: ' + test.platform.join(','))
console.log('Passed: ' + passed.toString())
console.log('Url ' + test.url)
}
}
}
taskIds.forEach(function (id) {
jsUnitSaucelabs.getStatus(id, waitingCallback)
})
}
})
})
jsUnitSaucelabs.initTunnel()