Skip to content

Commit f60c519

Browse files
committed
fix(test): treat failure to launch tests as a test failure
The previous formulation of the test runner was not catching promise rejections coming from the webdriver / browser. Node would print warnings to the console, but the test runner would exit with code 0 and CI would treat this as a passing build. Now the rejection is caught and reported, and the test runner exits with code 1. Existing functionality to look for failed test results has not changed.
1 parent 01dc89d commit f60c519

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

tests/jsunit/test_runner.js

+20-11
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,23 @@ var testHtml = function (htmlString) {
2424

2525
var path = process.cwd();
2626

27-
browser
28-
.get("file://" + path + "/tests/jsunit/vertical_tests.html")
29-
.then(function () { return browser.sleep(5000) })
30-
.then(function () { return browser.findElement({id: "closureTestRunnerLog"}) })
31-
.then(function (e) { return e.getText() })
32-
.then(testHtml)
33-
.then(function () { return browser.get("file://" + path + "/tests/jsunit/horizontal_tests.html")})
34-
.then(function () { return browser.sleep(5000) })
35-
.then(function () { return browser.findElement({id: "closureTestRunnerLog"}) })
36-
.then(function (e) { return e.getText() })
37-
.then(testHtml);
27+
var runTests = async function () {
28+
var element, text;
29+
30+
await browser.get("file://" + path + "/tests/jsunit/vertical_tests.html");
31+
await browser.sleep(5000);
32+
element = await browser.findElement({id: "closureTestRunnerLog"});
33+
text = await element.getText();
34+
testHtml(text);
35+
36+
await browser.get("file://" + path + "/tests/jsunit/horizontal_tests.html");
37+
await browser.sleep(5000);
38+
element = await browser.findElement({id: "closureTestRunnerLog"});
39+
text = await element.getText();
40+
testHtml(text);
41+
};
42+
43+
runTests().catch(e => {
44+
console.error(e);
45+
process.exit(1);
46+
});

0 commit comments

Comments
 (0)