Skip to content

Commit

Permalink
fix(test): treat failure to launch tests as a test failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cwillisf committed Jun 29, 2021
1 parent 01dc89d commit f60c519
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions tests/jsunit/test_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ var testHtml = function (htmlString) {

var path = process.cwd();

browser
.get("file://" + path + "/tests/jsunit/vertical_tests.html")
.then(function () { return browser.sleep(5000) })
.then(function () { return browser.findElement({id: "closureTestRunnerLog"}) })
.then(function (e) { return e.getText() })
.then(testHtml)
.then(function () { return browser.get("file://" + path + "/tests/jsunit/horizontal_tests.html")})
.then(function () { return browser.sleep(5000) })
.then(function () { return browser.findElement({id: "closureTestRunnerLog"}) })
.then(function (e) { return e.getText() })
.then(testHtml);
var runTests = async function () {
var element, text;

await browser.get("file://" + path + "/tests/jsunit/vertical_tests.html");
await browser.sleep(5000);
element = await browser.findElement({id: "closureTestRunnerLog"});
text = await element.getText();
testHtml(text);

await browser.get("file://" + path + "/tests/jsunit/horizontal_tests.html");
await browser.sleep(5000);
element = await browser.findElement({id: "closureTestRunnerLog"});
text = await element.getText();
testHtml(text);
};

runTests().catch(e => {
console.error(e);
process.exit(1);
});

0 comments on commit f60c519

Please # to comment.