Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function command() {
const saucelabs = new SauceLabs({
password: process.env.SAUCE_ACCESS_KEY,
username: process.env.SAUCE_USERNAME
});
const sessionid = this.capabilities['webdriver.remote.sessionid'];
const jobName = this.currentTest.name;
saucelabs.updateJob(sessionid, {
name: jobName,
passed: this.currentTest.results.failed === 0
}, () => {
// empty
});
this.end();
}
/* eslint-enable babel/no-invalid-this */
exports.command = function(callback) {
// sauce lab does not support the concept of branches, so only reporting the master results
if (process.env.BUILDKITE_BRANCH !== 'master') {
return callback();
}
const saucelabs = new SauceLabs({
username: process.env.SAUCE_USERNAME,
password: process.env.SAUCE_ACCESS_KEY,
});
const sessionId = this.capabilities['webdriver.remote.sessionid'];
const name = this.currentTest.name;
// TODO(#363): figure out how we can report proper test statuses for the master branch
saucelabs.updateJob(
sessionId,
{
passed: true,
name,
},
callback,
);
};
const reportResult = (client, done) => {
if (!process.env.TRAVIS) { return done(); }
const user = client.options.username;
const key = client.options.accessKey;
const jobId = client.capabilities['webdriver.remote.sessionid'];
if (user && key && jobId) {
const passed = client.currentTest.results.failed === 0;
console.log('* updating job status:', jobId, passed);
const 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();
module.exports = function sauce(client, callback) {
var currentTest = client.currentTest;
var username = client.options.username;
var sessionId = client.capabilities['webdriver.remote.sessionid'];
var accessKey = client.options.accessKey;
if (!username || !accessKey || !sessionId) {
console.log(client);
return callback();
}
var passed = currentTest.results.passed === currentTest.results.tests;
var data = JSON.stringify({ passed });
var axios = Axios.create({
baseURL: 'https://saucelabs.com',
auth: {
username: username,
password: accessKey
exports.command = function command(callback) {
const saucelabs = new SauceLabs({
username,
password: accessKey,
})
const sessionId = this.capabilities['webdriver.remote.sessionid']
const { name } = this.currentTest
const passed = this.currentTest.results.failed === 0
saucelabs.updateJob(sessionId, { passed, name }, callback)
return this
}
exports.command = function seleniumEnd(callback) {
const saucelabs = new SauceLabs({
username: image.username,
password: image.accessKey,
})
const sessionId = this.capabilities['webdriver.remote.sessionid']
const { name } = this.currentTest
const passed = this.currentTest.results.failed === 0
saucelabs.updateJob(sessionId, { passed, name }, callback)
return this
}
static _ensureSessionId (sessionInfo) {
const sessionData = sessionInfo.value || {};
const sessionCapabilities = sessionData.capabilities || {};
sessionInfo.sessionId = sessionInfo.sessionId ||
sessionData.sessionId ||
sessionData['webdriver.remote.sessionid'] ||
sessionCapabilities['webdriver.remote.sessionid'];
if (!sessionInfo.sessionId) {
throw new Error(ERROR_MESSAGES.SESSION_ID_NOT_FOUND({
sessionInfoDump: inspect(sessionInfo)
}));
}
}
static _ensureSessionId (sessionInfo) {
const sessionData = sessionInfo.value || {};
const sessionCapabilities = sessionData.capabilities || {};
sessionInfo.sessionId = sessionInfo.sessionId ||
sessionData.sessionId ||
sessionData['webdriver.remote.sessionid'] ||
sessionCapabilities['webdriver.remote.sessionid'];
if (!sessionInfo.sessionId) {
throw new Error(ERROR_MESSAGES.SESSION_ID_NOT_FOUND({
sessionInfoDump: inspect(sessionInfo)
}));
}
}
afterEach(browser, done) {
const SauceLabs = require('saucelabs');
const saucelabs = new SauceLabs({
username: process.env.SAUCE_USERNAME,
password: process.env.SAUCE_ACCESS_KEY,
});
const sessionid = browser.capabilities['webdriver.remote.sessionid'];
const jobName = browser.currentTest.module;
function noFailures(item) {
return item.failed === 0 && item.errors === 0;
}
const testCaseData = Object.keys(browser.currentTest.results.testcases).map(
key => browser.currentTest.results.testcases[key],
);
const passed = testCaseData.every(noFailures);
saucelabs.updateJob(
sessionid,
{
passed,