Skip to content

Commit

Permalink
Suppressing errors on request domains.
Browse files Browse the repository at this point in the history
Feature request: postmanlabs#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.
  • Loading branch information
Vijayarajan Ravindran committed Feb 9, 2023
1 parent 8994155 commit 4cd2179
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/newman.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <value>', 'Enable/Disable colored output (auto|on|off)', util.cast.colorOptions, 'auto')
Expand Down
10 changes: 10 additions & 0 deletions lib/run/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4cd2179

Please sign in to comment.