From 088dd420055b8278a53bf78cb26f1973106b8a6c Mon Sep 17 00:00:00 2001 From: Adam Gruber Date: Tue, 17 Jan 2017 15:59:05 -0500 Subject: [PATCH] Feature/exit code fix (#119) * remove babel-polyfill * pass failures through to mocha done function --- dist/mochawesome.js | 10 +++++----- src/mochawesome.js | 8 ++++---- test-functional/mocha.opts | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/dist/mochawesome.js b/dist/mochawesome.js index 28e7048..0f2e223 100755 --- a/dist/mochawesome.js +++ b/dist/mochawesome.js @@ -25,7 +25,7 @@ var _typeof3 = _interopRequireDefault(_typeof2); */ var done = function () { - var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(output, config, exit) { + var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(output, config, failures, exit) { var reportJsonFile, reportHtmlFile; return _regenerator2.default.wrap(function _callee$(_context) { while (1) { @@ -46,7 +46,7 @@ var done = function () { case 7: log('Report HTML saved to ' + reportHtmlFile, null, config); - exit(); + exit(failures); _context.next = 15; break; @@ -55,7 +55,7 @@ var done = function () { _context.t0 = _context['catch'](1); log(_context.t0, 'error', config); - exit(); + exit(failures); case 15: case 'end': @@ -65,7 +65,7 @@ var done = function () { }, _callee, this, [[1, 11]]); })); - return function done(_x, _x2, _x3) { + return function done(_x, _x2, _x3, _x4) { return _ref.apply(this, arguments); }; }(); @@ -338,7 +338,7 @@ function saveFile(filename, data) { // Done function will be called before mocha exits // This is where we will save JSON and generate the report this.done = function (failures, exit) { - return done(_this.output, _this.config, exit); + return done(_this.output, _this.config, failures, exit); }; // Reset total tests counter diff --git a/src/mochawesome.js b/src/mochawesome.js index efbcf87..de00f74 100755 --- a/src/mochawesome.js +++ b/src/mochawesome.js @@ -289,7 +289,7 @@ function saveFile(filename, data) { * @param {Function} exit */ -async function done(output, config, exit) { +async function done(output, config, failures, exit) { const { reportJsonFile, reportHtmlFile } = config; try { // Save the JSON to disk @@ -300,10 +300,10 @@ async function done(output, config, exit) { await marge.create(output, config); log(`Report HTML saved to ${reportHtmlFile}`, null, config); - exit(); + exit(failures); } catch (err) { log(err, 'error', config); - exit(); + exit(failures); } } @@ -317,7 +317,7 @@ async function done(output, config, exit) { function Mochawesome(runner, options) { // Done function will be called before mocha exits // This is where we will save JSON and generate the report - this.done = (failures, exit) => done(this.output, this.config, exit); + this.done = (failures, exit) => done(this.output, this.config, failures, exit); // Reset total tests counter totalTestsRegistered = 0; diff --git a/test-functional/mocha.opts b/test-functional/mocha.opts index 0b439f6..00154e1 100644 --- a/test-functional/mocha.opts +++ b/test-functional/mocha.opts @@ -1,5 +1,4 @@ --stack-trace --compilers js:babel-core/register ---require babel-polyfill --require should --reporter mochawesome \ No newline at end of file