Visually notify of uncaught exceptions breaking client tests (#9034)

* Visually notify of uncaught exceptions breaking client tests

These changes add a global `window.onerror` event handler
to the `test-in-browser` package, to catch any previously
uncaught exceptions. When uncaught exceptions are found,
an alert box is displayed above the test results table.
This should help notify developers of hidden uncaught
exceptions that could be preventing client tests from
running.

Fixes #4979.

* Bump the test-in-browser package version
This commit is contained in:
Hugh Willson
2017-08-22 20:52:30 -04:00
committed by Ben Newman
parent e027a46d71
commit cd5405437c
4 changed files with 52 additions and 9 deletions

View File

@@ -151,4 +151,8 @@ body {
#current-client-test {
color: #ccc;
margin-right: 15px;
}
}
.failedTests {
color: #900; /* red */
}

View File

@@ -1,6 +1,7 @@
<template name="testInBrowserBody">
<div class="container-fluid">
{{> navBars}}
{{> uncaughtErrors}}
{{> failedTests}}
{{> testTable}}
</div>
@@ -71,14 +72,38 @@
</div>
</template>
<template name="uncaughtErrors">
{{#if uncaughtErrors}}
<div class="row-fluid">
<div class="span12">
<div class="alert alert-danger">
<p>
<strong>WARNING:</strong> The following uncaught errors might be
preventing some client tests from running.
</p>
<ul>
{{#each uncaughtErrors}}
<li>{{this}}</li>
{{/each}}
</ul>
</div>
</div>
</div>
{{/if}}
</template>
<template name="failedTests">
<div class="row-fluid"><div class="span12">
<ul class="failedTests">
{{#each failedTests}}
<li>{{this}}</li>
{{/each}}
</ul>
</div></div>
{{#if failedTests}}
<div class="row-fluid">
<div class="span12">
<ul class="failedTests">
{{#each failedTests}}
<li>{{this}}</li>
{{/each}}
</ul>
</div>
</div>
{{/if}}
</template>
<template name="testTable">

View File

@@ -35,6 +35,12 @@ var topLevelGroupsDep = new Tracker.Dependency;
// - dep: Tracker.Dependency object for this test. fires when the test completes.
var resultTree = [];
Session.set("uncaughtErrors", []);
window.onerror = (message, source, line) => {
const uncaughtErrors = new Set(Session.get("uncaughtErrors"));
uncaughtErrors.add(message);
Session.set("uncaughtErrors", Array.from(uncaughtErrors));
};
Session.setDefault("groupPath", ["tinytest"]);
Session.set("rerunScheduled", false);
@@ -359,6 +365,13 @@ Template.groupNav.onRendered(function () {
};
});
//// Template - uncaughtErrors
Template.uncaughtErrors.helpers({
uncaughtErrors() {
return Session.get("uncaughtErrors");
}
});
//// Template - failedTests

View File

@@ -1,10 +1,11 @@
Package.describe({
summary: "Run tests interactively in the browser",
version: '1.0.13',
version: '1.0.14',
documentation: null
});
Package.onUse(function (api) {
api.use('ecmascript');
// XXX this should go away, and there should be a clean interface
// that tinytest and the driver both implement?
api.use('tinytest');