UNPKG

869 BJavaScriptView Raw
1window.failedTests = [];
2
3window.runner = null;
4
5mocha.run = (function() {
6 var orig;
7 orig = mocha.run.bind(mocha);
8 return function() {
9 var runner;
10 runner = orig.apply(null, arguments);
11 runner.on('end', function() {
12 window.mochaResults = runner.stats || {};
13 return window.mochaResults.reports = window.failedTests;
14 });
15 runner.on('pass', function() {});
16 runner.on('fail', function(test, err) {
17 return failedTests.push({
18 name: test.title,
19 result: false,
20 message: err.message,
21 stack: err.stack,
22 titles: (function() {
23 var titles;
24 titles = [];
25 while (test.parent.title) {
26 titles.push(test.parent.title);
27 test = test.parent;
28 }
29 return titles.reverse();
30 })()
31 });
32 });
33 return runner;
34 };
35})();
36