Skip to content

Commit

Permalink
report e2e test result to SauceLabs
Browse files Browse the repository at this point in the history
  • Loading branch information
outsideris committed Nov 15, 2017
1 parent d2ec39b commit a260af0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/e2e/initialization.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const sauce = require('../libs/sauce');

module.exports = {
'Initialization': function(client) {
after: sauce.reportPassed,

'Initialization': (client) => {
/* eslint-disable */
client.url(client.launch_url + '/initialization.html').pause(1000);

Expand Down
35 changes: 35 additions & 0 deletions test/libs/sauce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// from: https://github.com/RTICWDT/college-scorecard/blob/8029b46f1283ed94c7f13662689374c399ff6740/test/sauce.js
var request = require('request');

var reportPassed = function(client, done) {
if (!process.env.TRAVIS) { return done(); }

var user = client.options.username;
var key = client.options.accessKey;
var jobId = client.sessionId;
// console.log('client options:', client.options, '->', [user, key, jobId]);
if (user && key && jobId) {
var passed = client.currentTest.results.failed === 0;
console.log('* updating job status:', jobId, passed);
var url = 'https://saucelabs.com/rest/v1/' + user + '/jobs/' + jobId;
return request.put({
url: url,
auth: {
username: user,
password: key
},
headers: {'content-type': 'application/json'},
body: JSON.stringify({passed: passed})
}, function(res, status, body) {
console.log('Sauce response:', body);
done();
});
} else {
console.log('not updating job status (no sauce creds?)');
return done();
}
};

module.exports = {
reportPassed: reportPassed
};

0 comments on commit a260af0

Please sign in to comment.