Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/runners/webdriver.js

Issue 29874649: Issue 6822 - Report browser test errors (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Minor reformat Created Sept. 14, 2018, 12:37 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/runners/webdriver.js
===================================================================
--- a/test/runners/webdriver.js
+++ b/test/runners/webdriver.js
@@ -19,26 +19,26 @@
function executeScript(driver, name, script, scriptName, scriptArgs)
{
let realScript = `let f = ${script}
let callback = arguments[arguments.length - 1];
return Promise.resolve()
.then(() => f(...arguments))
.then(() => callback());`;
- return driver.executeScript(`window.consoleLogs = [];
- let oldLog = console.log;
+ return driver.executeScript(`let oldLog = console.log;
console.log = msg => {
Sebastian Noack 2018/09/17 16:18:06 What is about console.error(), console.warn(), etc
hub 2018/09/18 22:23:36 Only console.log is used for reporting test result
- window.consoleLogs.push(msg);
+ window.consoleLogs.log.push(msg);
oldLog.call(this, msg);
};`)
.then(() => driver.executeAsyncScript(realScript, scriptArgs))
.then(() => driver.executeScript("return window.consoleLogs;"))
.then(result =>
{
console.log(`\nBrowser tests in ${name}\n`);
- result.forEach(item => console.log(item));
+ result.log.forEach(item => console.log(item));
Sebastian Noack 2018/09/17 16:18:06 Nit: We generally prefer for..of loops of .forEach
hub 2018/09/18 22:23:36 Done.
+ if (result.failures != 0)
+ return Promise.reject("Test failure");
})
- .then(() => driver.quit())
- ;
+ .finally(() => driver.quit());
Sebastian Noack 2018/09/17 16:18:06 .finally() requires Node.js 10, but we still suppo
hub 2018/09/18 22:23:36 I have run this on Node 7 and 8 and it did work. I
Sebastian Noack 2018/09/19 08:16:50 I'm on Node.js 8.5.0 and Promise.resolve().finally
}
module.exports.executeScript = executeScript;

Powered by Google App Engine
This is Rietveld