diff --git a/lib/TransactionRunner.js b/lib/TransactionRunner.js index b8c33b5dd..d70b8919e 100644 --- a/lib/TransactionRunner.js +++ b/lib/TransactionRunner.js @@ -338,7 +338,7 @@ class TransactionRunner { failTransaction(transaction, reason) { transaction.fail = true; - this.ensureTransactionResultsGeneralSection(transaction); + this.ensureTransactionErrors(transaction); if (reason) { transaction.errors.push({ severity: 'error', message: reason }); } if (!transaction.test) { transaction.test = this.createTest(transaction); } @@ -363,7 +363,7 @@ class TransactionRunner { skipTransaction(transaction, reason) { transaction.skip = true; - this.ensureTransactionResultsGeneralSection(transaction); + this.ensureTransactionErrors(transaction); if (reason) { transaction.errors.push({ severity: 'warning', message: reason }); } if (!transaction.test) { transaction.test = this.createTest(transaction); } @@ -376,16 +376,16 @@ class TransactionRunner { results = transaction.test.results = transaction.results; } - // Ensure transaction errors are propagates to the test. - // That way transaction errors are a part of an Apiary Reporter. + // Ensure transaction errors propagate to the test. + // That way transaction errors can make it to reporters. transaction.test.errors = transaction.errors; return results; } - // Ensures that given transaction object has 'results' with 'general' section - // where custom Gavel-like errors or warnings can be inserted. - ensureTransactionResultsGeneralSection(transaction) { + // Ensures that given transaction object has the "errors" key + // where custom test run errors (not validation errors) are stored. + ensureTransactionErrors(transaction) { if (!transaction.results) { transaction.results = {}; } if (!transaction.errors) { transaction.errors = []; } @@ -446,7 +446,7 @@ class TransactionRunner { logger.debug('Emitting to reporters: test start'); this.configuration.emitter.emit('test start', test, eventCallback); - this.ensureTransactionResultsGeneralSection(transaction); + this.ensureTransactionErrors(transaction); if (transaction.skip) { logger.debug('HTTP transaction was marked in hooks as to be skipped. Skipping'); diff --git a/lib/reporters/ApiaryReporter.js b/lib/reporters/ApiaryReporter.js index abd03f59d..efa8bc6be 100644 --- a/lib/reporters/ApiaryReporter.js +++ b/lib/reporters/ApiaryReporter.js @@ -150,9 +150,6 @@ ApiaryReporter.prototype.configureEmitter = function configureEmitter(emitter) { if (this.serverError === true) { return callback(); } const data = this._transformTestToReporter(test); - if (!data.results.errors) { data.results.errors = []; } - if (!data.results.validationResult) { data.results.validationResult = {}; } - if (Array.from(CONNECTION_ERRORS).includes(error.code)) { data.results.errors.push({ severity: 'error', message: 'Error connecting to server under test!', @@ -281,8 +278,8 @@ ApiaryReporter.prototype._transformTestToReporter = function _transformTestToRep request: test.request, realResponse: test.actual, expectedResponse: test.expected, - validationResult: test.results, - errors: test.errors, + validationResult: test.results || {}, + errors: test.errors || [], }, }; };