mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
better error handling for jasmine task
This commit is contained in:
@@ -7,10 +7,12 @@ module.exports = function(){
|
||||
|
||||
var desiredCapabilities = {};
|
||||
if (config.desiredCapabilities) Object.keys(config.desiredCapabilities).forEach(function(key){
|
||||
if (config.desiredCapabilities[key] === undefined) return;
|
||||
desiredCapabilities[key] = config.desiredCapabilities[key];
|
||||
});
|
||||
grunt.verbose.writeln("desiredCapabilities", JSON.stringify(desiredCapabilities));
|
||||
|
||||
grunt.verbose.write('webdriver remote', JSON.stringify(config.webdriver.remote));
|
||||
grunt.verbose.writeln('webdriver remote', JSON.stringify(config.webdriver.remote));
|
||||
var browser = wd.promiseChainRemote(config.webdriver.remote);
|
||||
|
||||
browser.on('status', function(info) {
|
||||
@@ -21,21 +23,38 @@ module.exports = function(){
|
||||
grunt.verbose.writeln(' > ' + meth, path, data || '');
|
||||
});
|
||||
|
||||
var report = null;
|
||||
|
||||
// browser._debugPromise();
|
||||
browser
|
||||
.init(desiredCapabilities)
|
||||
.then(config.onStart && config.onStart.bind(config, browser))
|
||||
.get(config.url)
|
||||
.then(function(){return browser;})
|
||||
.then(getJSReport)
|
||||
.then(config.onComplete && config.onComplete.bind(browser), config.onError && config.onError.bind(browser))
|
||||
.fail(grunt.verbose.writeln.bind(grunt.verbose))
|
||||
.fin(function(){
|
||||
.then(function(data){ report = data; })
|
||||
.fail(function(error){
|
||||
grunt.log.error(error);
|
||||
return browser
|
||||
.eval('document.documentElement.innerText || document.documentElement.textContent')
|
||||
.then(grunt.verbose.writeln.bind(grunt.verbose))
|
||||
.then(function(){throw error})
|
||||
;
|
||||
})
|
||||
.finally(function(){
|
||||
if (grunt.option('webdriver-keep-open')) return;
|
||||
grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
|
||||
return browser.quit();
|
||||
})
|
||||
.done(
|
||||
taskSucceeded.bind(null,true),
|
||||
taskSucceeded.bind(null,false)
|
||||
function(){
|
||||
if (config.onComplete) config.onComplete(report);
|
||||
taskSucceeded(true);
|
||||
},
|
||||
function(error){
|
||||
if (config.onError) config.onError(error);
|
||||
taskSucceeded(false);
|
||||
}
|
||||
)
|
||||
;
|
||||
}
|
||||
@@ -43,6 +62,9 @@ module.exports = function(){
|
||||
function getJSReport(browser){
|
||||
return browser
|
||||
.waitForCondition("typeof window.jasmine != 'undefined'", 500)
|
||||
.fail(function(error){
|
||||
throw Error("The test page didn't load properly. " + error);
|
||||
})
|
||||
.waitForCondition("typeof window.jasmine.getJSReport != 'undefined'", 10e3)
|
||||
.waitForCondition("window.testImageURL.running <= 0", 5e3)
|
||||
.eval("jasmine.getJSReport()")
|
||||
|
||||
Reference in New Issue
Block a user