diff options
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | spec/amd.html | 32 | ||||
-rw-r--r-- | spec/index.html | 32 |
3 files changed, 63 insertions, 3 deletions
diff --git a/package.json b/package.json index 9bfc957..d7eb39a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "grunt-contrib-requirejs": "~0.4.1", "grunt-contrib-uglify": "~0.2.2", "grunt-contrib-watch": "~0.5.3", - "grunt-saucelabs": "~4.1.2", + "grunt-saucelabs": "~5.0.1", "es6-module-packager": "1.x", "jison": "~0.3.0", "keen.io": "0.0.3", diff --git a/spec/amd.html b/spec/amd.html index a095650..ef33e61 100644 --- a/spec/amd.html +++ b/spec/amd.html @@ -62,11 +62,41 @@ window.Handlebars = Handlebars['default']; require(['tests'], function(Handlebars) { + mocha.globals(['mochaResults']) // The test harness leaks under FF. We should have decent global leak coverage from other tests if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) { mocha.checkLeaks(); } - mocha.run(); + var runner = mocha.run(); + + //Reporting for saucelabs + var failedTests = []; + runner.on('end', function(){ + window.mochaResults = runner.stats; + window.mochaResults.reports = failedTests; + }); + + runner.on('fail', logFailure); + + function logFailure(test, err){ + + var flattenTitles = function(test){ + var titles = []; + while (test.parent.title){ + titles.push(test.parent.title); + test = test.parent; + } + return titles.reverse(); + }; + + failedTests.push({ + name: test.title, + result: false, + message: err.message, + stack: err.stack, + titles: flattenTitles(test) + }); + }; }); }); }; diff --git a/spec/index.html b/spec/index.html index fe306e7..4a064cb 100644 --- a/spec/index.html +++ b/spec/index.html @@ -50,11 +50,41 @@ <script src="/tmp/tests.js"></script> <script> onload = function(){ + mocha.globals(['mochaResults']) // The test harness leaks under FF. We should have decent global leak coverage from other tests if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) { mocha.checkLeaks(); } - mocha.run(); + var runner = mocha.run(); + + //Reporting for saucelabs + var failedTests = []; + runner.on('end', function(){ + window.mochaResults = runner.stats; + window.mochaResults.reports = failedTests; + }); + + runner.on('fail', logFailure); + + function logFailure(test, err){ + + var flattenTitles = function(test){ + var titles = []; + while (test.parent.title){ + titles.push(test.parent.title); + test = test.parent; + } + return titles.reverse(); + }; + + failedTests.push({ + name: test.title, + result: false, + message: err.message, + stack: err.stack, + titles: flattenTitles(test) + }); + }; }; </script> </head> |