mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Refactor webdriver test running
This commit is contained in:
parent
d2bfb810d4
commit
503add6e2f
@ -129,11 +129,11 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('webdriver', 'Browser render tests', function() {
|
grunt.registerTask('webdriver', 'Browser render tests', function(browser, test) {
|
||||||
var selenium = require("./tests/selenium.js");
|
var selenium = require("./tests/selenium.js");
|
||||||
var done = this.async();
|
var done = this.async();
|
||||||
var browsers = (this.args.length) ? [grunt.config.get(this.nameArgs.replace(":", "."))] : _.values(grunt.config.get(this.name));
|
var browsers = (browser) ? [grunt.config.get(this.name + "." + browser)] : _.values(grunt.config.get(this.name));
|
||||||
selenium.tests(browsers).onValue(done);
|
selenium.tests(browsers, test).onValue(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load tasks
|
// Load tasks
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"baconjs": "0.7.11",
|
"baconjs": "0.7.11",
|
||||||
"base64-arraybuffer": ">= 0.1.0",
|
"base64-arraybuffer": ">= 0.1.0",
|
||||||
"grunt": ">=0.4.0",
|
"grunt": "^0.4.5",
|
||||||
"grunt-contrib-concat": "*",
|
"grunt-contrib-concat": "*",
|
||||||
"grunt-contrib-connect": "0.7.1",
|
"grunt-contrib-connect": "0.7.1",
|
||||||
"grunt-contrib-jshint": "*",
|
"grunt-contrib-jshint": "*",
|
||||||
|
@ -127,7 +127,10 @@
|
|||||||
var browserStream = new Bacon.Bus();
|
var browserStream = new Bacon.Bus();
|
||||||
if (process.env.TRAVIS_JOB_NUMBER) {
|
if (process.env.TRAVIS_JOB_NUMBER) {
|
||||||
test.capabilities["tunnel-identifier"] = process.env.TRAVIS_JOB_NUMBER;
|
test.capabilities["tunnel-identifier"] = process.env.TRAVIS_JOB_NUMBER;
|
||||||
test.capabilities["name"] = process.env.TRAVIS_COMMIT.substring(0, 10) + " #" + process.env.TRAVIS_BUILD_NUMBER;
|
test.capabilities["name"] = process.env.TRAVIS_COMMIT.substring(0, 10);
|
||||||
|
test.capabilities["build"] = process.env.TRAVIS_BUILD_NUMBER;
|
||||||
|
} else {
|
||||||
|
test.capabilities["name"] = "Manual run";
|
||||||
}
|
}
|
||||||
|
|
||||||
var resultStream = Bacon.fromNodeCallback(browser, "init", test.capabilities)
|
var resultStream = Bacon.fromNodeCallback(browser, "init", test.capabilities)
|
||||||
@ -144,7 +147,8 @@
|
|||||||
return Bacon.fromNodeCallback(browser, "execute", "return arguments[0].toDataURL('image/png').substring(22)", [canvas]);
|
return Bacon.fromNodeCallback(browser, "execute", "return arguments[0].toDataURL('image/png').substring(22)", [canvas]);
|
||||||
}),
|
}),
|
||||||
screenshot: Bacon.fromNodeCallback(browser, "takeScreenshot")
|
screenshot: Bacon.fromNodeCallback(browser, "takeScreenshot")
|
||||||
})).flatMap(function(result) {
|
}))
|
||||||
|
.flatMap(function(result) {
|
||||||
return Bacon.combineTemplate({
|
return Bacon.combineTemplate({
|
||||||
browser: name,
|
browser: name,
|
||||||
testCase: testCase,
|
testCase: testCase,
|
||||||
@ -160,6 +164,7 @@
|
|||||||
var name = formatResultName(test.capabilities);
|
var name = formatResultName(test.capabilities);
|
||||||
console.log(colors.red, "ERROR", name, error.message);
|
console.log(colors.red, "ERROR", name, error.message);
|
||||||
browserStream.push(name);
|
browserStream.push(name);
|
||||||
|
browser.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
resultStream.onValue(function(result) {
|
resultStream.onValue(function(result) {
|
||||||
@ -207,7 +212,7 @@
|
|||||||
return result.fold([], pushToArray);
|
return result.fold([], pushToArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.tests = function(browsers) {
|
exports.tests = function(browsers, singleTest) {
|
||||||
return getTests("tests/cases").fold([], pushToArray).flatMap(runWebDriver.bind(null, browsers)).mapError(false);
|
return (singleTest ? Bacon.constant([singleTest]) : getTests("tests/cases").fold([], pushToArray)).flatMap(runWebDriver.bind(null, browsers)).mapError(false);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user