npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

newman-async-runner

v1.2.3

Published

Asynchronous matrix test runner for newman

Downloads

330

Readme

Newman Async Runner

newman async runner lets you run your local and online (API) postman collections asynchronously as all-against-all matrix for:

-> collections or their specific folders/items

-> environments

-> iteration data files

diagram

It uses htmlfull reporter - however this can be easily override by passing custom newmanOptions, see API

Installation


npm i newman-async-runner

Usage

You need to simply instantiate NewmanRunner with runnerOptions as parameter and call runTests()

const runner = require('newman-async-runner');

const runnerOptions = {
		folders: {
			collections:'./collections/',
			environments: './environments/',
			reports: './reports/', 
			data: './data/',
		},
		newmanOptions: {
			timeoutRequest: 10000
		}
	};

new runner.NewmanRunner(runnerOptions).runTests();

Integration with other tools

Runner can be easily paired with popular test frameworks like Mocha or Jest. runTests() method returns array of default newman results array [error, summary] for each run in matrix. Simple Mocha example with chai:

console.log = function(){};
const expect = require('chai').expect;
const runner = require('newman-async-runner').NewmanRunner;

const UAT = {
	folders:
		{collections:'https://api.getpostman.com/collections/?apikey=YOUR_POSTMAN_API_KEY'},
	specific_collection_items_to_run: ['test folder A', 'test folder B'],
	newmanOptions:
		{reporters: 'htmlfull'}
	};

const SIT = {
	folders:
		{collections:'https://api.getpostman.com/collections/?apikey=YOUR_POSTMAN_API_KEY'},
	specific_collection_items_to_run: ['test folder C', 'test folder D', 'test folder E'],
	newmanOptions:
		{reporters: 'htmlfull'} 
	};

describe('My Application API tests', function(){
	this.timeout(10000)
	
	it('passes all UAT tests', async function(){
		for (const eachResult of await new runner(UAT).runTests()){
			expect(eachResult.summary.run.failures).to.be.empty;
		}
	})

	it('passes all SIT tests', async function(){
		for (const eachResult of await new runner(SIT).runTests()){
			expect(eachResult.summary.run.failures).to.be.empty;
		}
	})
})

...and the result should be something like:

  My Application API tests
    √ passes all UAT tests (2989ms)
    √ passes all SIT tests (2137ms)

  2 passing (5s)

API

runnerOptions:

example of available options:

const runnerOptions = {
	folders: {
		collections:'./collections/',
		environments: './environments/',
		reports: './reports/', 
		data: './data/',
		templates: './templates/'},

	reporter_template: 'htmlreqres.hbs',
	anonymizeFilter: /(?<=\<password:\>)(.*?)(?=\<\\password\>)/g,
	specific_collection_items_to_run: ['folder 1', 'folder 2'],
	parallelFolderRuns: false,
	
	newmanOptions: {
		color: 'off',
		timeoutRequest: 10000
	}
};
folders : MANDATORY object

-> collections : MANDATORY string local path or online (postman API) uri to collections folder or single file.

-> environments : optional string local path or online (postman API) uri to environments folder or single file.

-> reports : optional string local path to reports output folder.

-> data : optional string local path to test run iteration data folder or single file.

-> templates : optional string local path to htmlfull templates folder.

reporter_template : optional string - htmlfull reporter specific template filename located in local options.templates folder. If not used runner will use default htmlfull template.

anonymizeFilter : optional js regex expression - report file anonymize regex filter. Runner will put *** in place of matching groups. If not used runner will not anonymize reports.

specific_collection_items_to_run : optional string array - specific collection(s) folder/item names to run from all collections or single collection located under options.collections path. If not used runner will run all folders and items in collection(s). In case of nested collection sub-folders it will trigger run for last matching folder/item, this is by newman design.

parallelFolderRuns : optional boolean will atomize each collection into separate folder and item runs. USE ONLY WITH options.specific_collection_items_to_run SET. Otherwise it will trigger separate run for each item in collection ;) When setup correctly this may speed-up whole collection execution time but may also clog it if there are too many runs. It will also generate much more report files since these produces separate run for each item. Also beware of default Node heap allocation limit (1.7GB for V8).

newmanOptions:optional object this will pass-trough any standard nemwan.run() options. In case of conflict it overwrites options used by newman-async-runner.

runnerMethods:

runTests() - asynchronously (all runs at once) fires newman test runs matrix for each combination of environment, collection and iteration data files. It will pass already pre-fetched data to newman, so in case of giving postman api uri paths in options.folder runner will minimize api calls needed - currently there are 60 calls/minute limit for postman api. Method returns standard newman [error, summary] results array for each run in matrix, so it can be processed same way as newman callback arguments.

Roadmap

  • fetch collection, environment and data files trough any http raw data source

License

MIT