Delicious testing

This commit is contained in:
Caleb James DeLisle
2017-05-31 19:40:17 +02:00
parent 7b94106bac
commit 24f37ea414
3 changed files with 64 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
/* global process */
var WebDriver = require("selenium-webdriver");
var nThen = require('nthen');
if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
// We can't do saucelabs on pull requests so don't fail.
@@ -21,18 +22,30 @@ if (process.env.SAUCE_USERNAME !== undefined) {
driver = new WebDriver.Builder().withCapabilities({ browserName: "chrome" }).build();
}
driver.get('http://localhost:3000/assert/');
var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
report.getAttribute("class").then(function (cls) {
report.getText().then(function (text) {
console.log("\n-----\n" + text + "\n-----");
driver.quit();
if (!cls) {
throw new Error("cls is null");
} else if (cls.indexOf("failure") !== -1) {
throw new Error("cls contains the word failure");
} else if (cls.indexOf("success") === -1) {
throw new Error("cls does not contain the word success");
}
});
var nt = nThen;
[
'/assert/',
'/auth/#?test=test'
].forEach(function (path) {
var url = 'http://localhost:3000' + path;
nt = nThen(function (waitFor) {
driver.get(url);
var report = driver.wait(WebDriver.until.elementLocated(WebDriver.By.className("report")), 5000);
report.getAttribute("class").then(waitFor(function (cls) {
report.getText().then(waitFor(function (text) {
console.log("\n-----\n" + url + ' ' + text + "\n-----");
if (!cls) {
throw new Error("cls is null");
} else if (cls.indexOf("failure") !== -1) {
throw new Error("cls contains the word failure");
} else if (cls.indexOf("success") === -1) {
throw new Error("cls does not contain the word success");
}
}));
}));
}).nThen;
});
nt(function () {
driver.quit();
})