Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropped support for Node < v18 #3286

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
380 changes: 175 additions & 205 deletions .eslintrc

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16, 18]
node-version: [18, 20]
os: [ubuntu-latest, windows-latest]

steps:
Expand All @@ -47,10 +47,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js 20
- name: Use latest Node.js
uses: actions/setup-node@v3
with:
node-version: 20
node-version: latest
cache: "npm"

- name: Install
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
unreleased:
breaking changes:
- GH-1605 Dropped support for Node < v18
chores:
- GH-1605 Updated dependencies
- GH-1605 Updated ESLint rules
- GH-1605 Run code coverage on latest Node version in CI

6.2.1:
date: 2024-08-20
fixed bugs:
Expand Down
1 change: 1 addition & 0 deletions examples/run-collections-in-directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fs.readdir('./examples', function (err, files) {
newman.run({
// we load collection using require. for better validation and handling
// JSON.parse could be used
// eslint-disable-next-line n/no-path-concat
collection: require(`${__dirname}/${file}`)
}, function (err) {
// finally, when the collection executes, print the status
Expand Down
2 changes: 1 addition & 1 deletion lib/config/rc-file.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-process-env */
/* eslint-disable n/no-process-env */
var _ = require('lodash'),
fs = require('fs'),
join = require('path').join,
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/cli/cli-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ cliUtils = {
}

return {
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line n/no-process-env
width: width,
height: height
};
Expand Down
102 changes: 53 additions & 49 deletions lib/reporters/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ PostmanCLIReporter = function (emitter, reporterOptions, options) {
}

reqText = wrap(reqText, ` ${colors.white(symbols.console.middle)} `);
// eslint-disable-next-line max-len
// eslint-disable-next-line @stylistic/js/max-len
print.buffer(` ${colors.white(symbols.console.top)} ${colors.white(symbols.up)} ${reqBodyMode} ${colors.gray(symbols.star)} ${util.filesize(reqTextLen)}\n`,
colors.white(` ${symbols.console.bottom}`))
// tweak the message to ensure that its surrounding is not brightly coloured.
Expand All @@ -278,7 +278,7 @@ PostmanCLIReporter = function (emitter, reporterOptions, options) {
}

resText = wrap(resText, ` ${colors.white(symbols.console.middle)} `);
// eslint-disable-next-line max-len
// eslint-disable-next-line @stylistic/js/max-len
print.buffer(` ${colors.white(symbols.console.top)} ${colors.white(symbols.down)} ${resSummary} ${colors.gray(symbols.star)} ${util.filesize(resTextLen)}\n`,
colors.white(` ${symbols.console.bottom}`))
// tweak the message to ensure that its surrounding is not brightly coloured.
Expand Down Expand Up @@ -443,38 +443,40 @@ _.assignIn(PostmanCLIReporter, {
});

// add specific rows to show in summary
stats && _.forEach([{
source: 'iterations',
label: 'iterations'
}, {
source: 'requests',
label: 'requests'
}, {
source: 'testScripts',
label: 'test-scripts'
}, {
source: 'prerequestScripts',
label: 'prerequest-scripts'
}, {
source: 'assertions',
label: 'assertions'
}], function (row) {
var metric = stats[row.source],
label = row.label;

// colour the label based on the failure or pending count of the metric
label = metric.failed ? colors.red(label) : (metric.pending ? label : colors.green(label));

// push the statistics
summaryTable.push([
label,
metric.total,
(metric.failed ? colors.red(metric.failed) : metric.failed)
// @todo - add information of pending scripts
// (metric.failed ? colors.red(metric.failed) : metric.failed) +
// (metric.pending ? format(' (%d pending)', metric.pending) : E)
]);
});
if (stats) {
_.forEach([{
source: 'iterations',
label: 'iterations'
}, {
source: 'requests',
label: 'requests'
}, {
source: 'testScripts',
label: 'test-scripts'
}, {
source: 'prerequestScripts',
label: 'prerequest-scripts'
}, {
source: 'assertions',
label: 'assertions'
}], function (row) {
var metric = stats[row.source],
label = row.label;

// colour the label based on the failure or pending count of the metric
label = metric.failed ? colors.red(label) : (metric.pending ? label : colors.green(label));

// push the statistics
summaryTable.push([
label,
metric.total,
(metric.failed ? colors.red(metric.failed) : metric.failed)
// @todo - add information of pending scripts
// (metric.failed ? colors.red(metric.failed) : metric.failed) +
// (metric.pending ? format(' (%d pending)', metric.pending) : E)
]);
});
}

// add the total execution time to summary
timings && summaryTable.push([{
Expand All @@ -491,21 +493,23 @@ _.assignIn(PostmanCLIReporter, {
}]);

// add rows containing average time of different request phases
timings && _.forEach({
response: 'average response time:',
dns: 'average DNS lookup time:',
firstByte: 'average first byte time:'
}, (value, key) => {
timings[`${key}Average`] && summaryTable.push([{
colSpan: 3,
content: format(`${value} %s [min: %s, max: %s, s.d.: %s]`,
util.prettyms(timings[`${key}Average`]),
util.prettyms(timings[`${key}Min`]),
util.prettyms(timings[`${key}Max`]),
util.prettyms(timings[`${key}Sd`])),
hAlign: 'left'
}]);
});
if (timings) {
_.forEach({
response: 'average response time:',
dns: 'average DNS lookup time:',
firstByte: 'average first byte time:'
}, (value, key) => {
timings[`${key}Average`] && summaryTable.push([{
colSpan: 3,
content: format(`${value} %s [min: %s, max: %s, s.d.: %s]`,
util.prettyms(timings[`${key}Average`]),
util.prettyms(timings[`${key}Min`]),
util.prettyms(timings[`${key}Max`]),
util.prettyms(timings[`${key}Sd`])),
hAlign: 'left'
}]);
});
}

return summaryTable;
},
Expand Down
2 changes: 1 addition & 1 deletion lib/run/export-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = function (options, done) {
});
},
function (next) {
fs.stat(path.unparsed, function (err, stat) { // eslint-disable-line handle-callback-err
fs.stat(path.unparsed, function (err, stat) { // eslint-disable-line n/handle-callback-err
next(null, stat);
});
},
Expand Down
101 changes: 52 additions & 49 deletions lib/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,64 +360,67 @@ module.exports = function (options, callback) {

// initialise all the reporters
!emitter.reporters && (emitter.reporters = {});
_.isArray(reporters) && _.forEach(reporters, function (reporterName) {
// disallow duplicate reporter initialisation
if (_.has(emitter.reporters, reporterName)) { return; }

var Reporter;
if (_.isArray(reporters)) {
_.forEach(reporters, function (reporterName) {
// disallow duplicate reporter initialisation
if (_.has(emitter.reporters, reporterName)) { return; }

try {
// check if the reporter is an external reporter
Reporter = require((function (name) { // ensure scoped packages are loaded
var prefix = '',
scope = (name.charAt(0) === '@') && name.substr(0, name.indexOf('/') + 1);
var Reporter;

if (scope) {
prefix = scope;
name = name.substr(scope.length);
}
try {
// check if the reporter is an external reporter
Reporter = require((function (name) { // ensure scoped packages are loaded
var prefix = '',
scope = (name.charAt(0) === '@') && name.substr(0, name.indexOf('/') + 1);

return prefix + 'newman-reporter-' + name;
}(reporterName)));
}
// @todo - maybe have a debug mode and log error there
catch (error) {
if (!defaultReporters[reporterName]) {
// @todo: route this via print module to respect silent flags
console.warn(`newman: could not find "${reporterName}" reporter`);
console.warn(' ensure that the reporter is installed in the same directory as newman');

// print install instruction in case a known reporter is missing
if (knownReporterErrorMessages[reporterName]) {
console.warn(knownReporterErrorMessages[reporterName]);
}
else {
console.warn(' please install reporter using npm\n');
if (scope) {
prefix = scope;
name = name.substr(scope.length);
}

return prefix + 'newman-reporter-' + name;
}(reporterName)));
}
// @todo - maybe have a debug mode and log error there
catch (error) {
if (!defaultReporters[reporterName]) {
// @todo: route this via print module to respect silent flags
console.warn(`newman: could not find "${reporterName}" reporter`);
console.warn(' ensure that the reporter is installed in the same directory as newman');

// print install instruction in case a known reporter is missing
if (knownReporterErrorMessages[reporterName]) {
console.warn(knownReporterErrorMessages[reporterName]);
}
else {
console.warn(' please install reporter using npm\n');
}
}
}
}

// load local reporter if its not an external reporter
!Reporter && (Reporter = defaultReporters[reporterName]);
// load local reporter if its not an external reporter
!Reporter && (Reporter = defaultReporters[reporterName]);

try {
// we could have checked _.isFunction(Reporter), here, but we do not do that so that the nature of
// reporter error can be bubbled up
Reporter && (emitter.reporters[reporterName] = new Reporter(emitter,
_.get(options, ['reporter', reporterName], {}), options));
}
catch (error) {
// if the reporter errored out during initialisation, we should not stop the run simply log
// the error stack trace for debugging
console.warn(`newman: could not load "${reporterName}" reporter`);

if (!defaultReporters[reporterName]) {
// @todo: route this via print module to respect silent flags
console.warn(` this seems to be a problem in the "${reporterName}" reporter.\n`);
try {
// we could have checked _.isFunction(Reporter), here, but we do
// not do that so that the nature of reporter error can be bubbled up
Reporter && (emitter.reporters[reporterName] = new Reporter(emitter,
_.get(options, ['reporter', reporterName], {}), options));
}
console.warn(error);
}
});
catch (error) {
// if the reporter errored out during initialisation, we should not stop the run simply log
// the error stack trace for debugging
console.warn(`newman: could not load "${reporterName}" reporter`);

if (!defaultReporters[reporterName]) {
// @todo: route this via print module to respect silent flags
console.warn(` this seems to be a problem in the "${reporterName}" reporter.\n`);
}
console.warn(error);
}
});
}

// raise warning when more than one dominant reporters are used
(function (reporters) {
Expand Down
16 changes: 10 additions & 6 deletions lib/run/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,17 @@ module.exports = function (options, callback) {
config.get(options, { loaders: configLoaders, command: 'run' }, function (err, result) {
if (err) { return callback(err); }

!_.isEmpty(options.globalVar) && _.forEach(options.globalVar, function (variable) {
variable && (result.globals.set(variable.key, variable.value));
});
if (!_.isEmpty(options.globalVar)) {
_.forEach(options.globalVar, function (variable) {
variable && (result.globals.set(variable.key, variable.value));
});
}

!_.isEmpty(options.envVar) && _.forEach(options.envVar, function (variable) {
variable && (result.environment.set(variable.key, variable.value));
});
if (!_.isEmpty(options.envVar)) {
_.forEach(options.envVar, function (variable) {
variable && (result.environment.set(variable.key, variable.value));
});
}

callback(null, result);
});
Expand Down
Loading
Loading