minor refactoring and hopefully we will be able to get the actual links to the tests on SauceLabs

pull/1/head
Caleb James DeLisle 9 years ago
parent 8709311a7e
commit 2d7309b04f

@ -1,8 +1,8 @@
language: node_js language: node_js
env: env:
matrix: matrix:
- "TEST_SUITE=saucelabs BROWSER='firefox:19:Windows 2012'" - "BROWSER='firefox:19:Windows 2012'"
- "TEST_SUITE=saucelabs BROWSER='chrome::Windows 2008'" - "BROWSER='chrome::Windows 2008'"
branches: branches:
only: only:
- master - master
@ -12,6 +12,7 @@ branches:
node_js: node_js:
- "4.2.1" - "4.2.1"
before_script: before_script:
- npm run-script lint
- cp config.js.dist config.js - cp config.js.dist config.js
- npm install - npm install
- npm install bower - npm install bower

@ -1,14 +1,15 @@
'use strict'; /* global process */
const WebDriver = require("selenium-webdriver"); var WebDriver = require("selenium-webdriver");
var Http = require("http");
let driver; var driver;
if (process.env.SAUCE_USERNAME != undefined) { if (process.env.SAUCE_USERNAME !== undefined) {
const browserArray = process.env.BROWSER.split(':'); var browserArray = process.env.BROWSER.split(':');
driver = new WebDriver.Builder().usingServer( driver = new WebDriver.Builder().usingServer(
'http://'+ process.env.SAUCE_USERNAME+':'+process.env.SAUCE_ACCESS_KEY+'@ondemand.saucelabs.com:80/wd/hub' 'http://'+ process.env.SAUCE_USERNAME+':'+process.env.SAUCE_ACCESS_KEY+'@ondemand.saucelabs.com:80/wd/hub'
).withCapabilities({ ).withCapabilities({
"tunnel-identifier": process.env.TRAVIS_JOB_NUMBER, "tunnel-identifier": process.env.TRAVIS_JOB_NUMBER,
"build": process.env.TRAVIS_BUILD_NUMBER, "build": process.env.TRAVIS_JOB_NUMBER,
"username": process.env.SAUCE_USERNAME, "username": process.env.SAUCE_USERNAME,
"accessKey": process.env.SAUCE_ACCESS_KEY, "accessKey": process.env.SAUCE_ACCESS_KEY,
}).forBrowser(browserArray[0], browserArray[1], browserArray[2]).build(); }).forBrowser(browserArray[0], browserArray[1], browserArray[2]).build();
@ -16,15 +17,36 @@ if (process.env.SAUCE_USERNAME != undefined) {
driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build(); driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build();
} }
var logSauceLink = function (cb) {
Http.request("https://saucelabs.com/rest/v1.1/" + process.env.SAUCE_USERNAME +
"/jobs?auto_only=true&full=true&limit=50&subaccounts=true", function (resp) {
var str = '';
resp.on('data', function (chunk) { str += chunk; });
resp.on('end', function () {
JSON.parse(str).jobs.forEach(function (j) {
var banner = new Array(80).join('=');
if (j.build === process.env.TRAVIS_JOB_NUMBER) {
console.log("\n\n\n" + banner);
console.log("SauceLabs Link: " + j.video_url.replace(/\/video\.flv$/), '');
console.log(banner + "\n\n\n");
}
});
cb();
});
});
};
driver.get('http://localhost:3000/assert/'); driver.get('http://localhost:3000/assert/');
const report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000); var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
report.getAttribute("class").then(function (cls) { report.getAttribute("class").then(function (cls) {
driver.quit(); driver.quit();
if (!cls) { logSauceLink(function () {
throw new Error("cls is null"); if (!cls) {
} else if (cls.indexOf("failure") !== -1) { throw new Error("cls is null");
throw new Error("cls contains the word failure"); } else if (cls.indexOf("failure") !== -1) {
} else if (cls.indexOf("success") === -1) { throw new Error("cls contains the word failure");
throw new Error("cls does not contain the word success"); } else if (cls.indexOf("success") === -1) {
} throw new Error("cls does not contain the word success");
}
});
}); });

Loading…
Cancel
Save