From 4cd21798c80af3db363dbe11f885e725ff9f45f6 Mon Sep 17 00:00:00 2001 From: Vijayarajan Ravindran Date: Thu, 9 Feb 2023 14:22:13 +0530 Subject: [PATCH] Suppressing errors on request domains. Feature request: https://github.com/postmanlabs/newman/issues/1918 Introduced a new command line argument named supressRequestErrors to newman cli. The new argument will receive a array of domain names to be ignored of their errors (DNS lookup errors). The Run Summary instance will suppress the errors if the errored url / domain is supplied by the user in this argument. --- bin/newman.js | 2 ++ lib/run/summary.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/bin/newman.js b/bin/newman.js index 31affd9a6..93db6d059 100755 --- a/bin/newman.js +++ b/bin/newman.js @@ -43,6 +43,8 @@ program ' and whether to end the run with an error based on the optional modifier', util.cast.csvParse) .option('--ignore-redirects', 'Prevents Newman from automatically following 3XX redirect responses') .option('-x , --suppress-exit-code', 'Specify whether or not to override the default exit code for the current run') + .option('--suppress-request-errors [hostnames]', 'Specify the hostnames to be ignored on request errors', + util.cast.csvParse, []) .option('--silent', 'Prevents Newman from showing output to CLI') .option('--disable-unicode', 'Forces Unicode compliant symbols to be replaced by their plain text equivalents') .option('--color ', 'Enable/Disable colored output (auto|on|off)', util.cast.colorOptions, 'auto') diff --git a/lib/run/summary.js b/lib/run/summary.js index 0779fffee..40976be5d 100644 --- a/lib/run/summary.js +++ b/lib/run/summary.js @@ -38,6 +38,13 @@ RunSummary = function RunSummary (emitter, options) { */ globals: _.get(options, 'globals'), + /** + * Hostnames ignored during the run failures + * + * @type {VariableScope} + */ + suppressRequestErrors: _.get(options, 'suppressRequestErrors'), + /** * Holds information related to the run. */ @@ -370,6 +377,9 @@ _.assign(RunSummary, { // push failures sent from "before" events emitter.on(event, function (err, o) { if (!err) { return; } + else if (_.isEqual('Error', err.name) && _.includes(summary.suppressRequestErrors, err.hostname)) { + return; + } var item = o && o.item, source = event;