diff --git a/lib/TransactionRunner.js b/lib/TransactionRunner.js index 2bc4a5a26..a758307ce 100644 --- a/lib/TransactionRunner.js +++ b/lib/TransactionRunner.js @@ -573,15 +573,18 @@ include a message body: https://tools.ietf.org/html/rfc7231#section-6.3\ let message = ''; const object = gavelResult || {}; let validatorOutput; - for (const sectionName of Object.keys(object || {})) { - // Section names are 'statusCode', 'headers', 'body' (and 'version', which is irrelevant) + + // Order-sensitive list of validation sections to output in the log + const resultSections = ['headers', 'body', 'statusCode'] + .filter(sectionName => Object.prototype.hasOwnProperty.call(object, sectionName)); + + resultSections.forEach((sectionName) => { validatorOutput = object[sectionName]; - if (sectionName !== 'version') { - for (const gavelError of validatorOutput.results || []) { - message += `${sectionName}: ${gavelError.message}\n`; - } - } - } + (validatorOutput.results || []).forEach((gavelError) => { + message += `${sectionName}: ${gavelError.message}\n`; + }); + }); + test.message = message; // Record raw validation output to transaction results object