Expose test results to sauce
* Do what blanket does, adding another level of indirection in the reporting.
This commit is contained in:
parent
94634fc77a
commit
5638b20046
2 changed files with 74 additions and 0 deletions
|
@ -16,6 +16,43 @@
|
||||||
mocha.setup("bdd");
|
mocha.setup("bdd");
|
||||||
window.assert = chai.assert;
|
window.assert = chai.assert;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var OriginalReporter = mocha._reporter;
|
||||||
|
|
||||||
|
var SauceReporter = function(runner) {
|
||||||
|
var failedTests = [];
|
||||||
|
|
||||||
|
runner.on('end', function() {
|
||||||
|
window.mochaResults = runner.stats;
|
||||||
|
window.mochaResults.reports = failedTests;
|
||||||
|
});
|
||||||
|
|
||||||
|
runner.on('fail', function(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)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
new OriginalReporter(runner);
|
||||||
|
};
|
||||||
|
|
||||||
|
SauceReporter.prototype = OriginalReporter.prototype;
|
||||||
|
|
||||||
|
mocha.reporter(SauceReporter);
|
||||||
|
}());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global helpers for tests
|
* global helpers for tests
|
||||||
*/
|
*/
|
||||||
|
|
37
test/test.js
37
test/test.js
|
@ -10890,6 +10890,43 @@ require.alias("chai/index.js", "chai/index.js");if (typeof exports == "object")
|
||||||
mocha.setup("bdd");
|
mocha.setup("bdd");
|
||||||
window.assert = chai.assert;
|
window.assert = chai.assert;
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var OriginalReporter = mocha._reporter;
|
||||||
|
|
||||||
|
var SauceReporter = function(runner) {
|
||||||
|
var failedTests = [];
|
||||||
|
|
||||||
|
runner.on('end', function() {
|
||||||
|
window.mochaResults = runner.stats;
|
||||||
|
window.mochaResults.reports = failedTests;
|
||||||
|
});
|
||||||
|
|
||||||
|
runner.on('fail', function(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)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
new OriginalReporter(runner);
|
||||||
|
};
|
||||||
|
|
||||||
|
SauceReporter.prototype = OriginalReporter.prototype;
|
||||||
|
|
||||||
|
mocha.reporter(SauceReporter);
|
||||||
|
}());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global helpers for tests
|
* global helpers for tests
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue