#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Installing and Running Newman

Prerequisites

Newman is distributed as an npm package, so Node.js and npm must be installed on your machine before you can install it.

Installing Newman

CommandPurpose
npm install -g newmanInstalls Newman globally on the system
newman -vConfirms the installed version

Exporting a Collection

Before running with Newman, export the collection (and environment, if used) as JSON files from Postman using the three-dot menu next to the collection name.

Running a Collection

The basic command is newman run collection.json. Adding -e environment.json applies a specific environment, and results are printed directly in the terminal.

With Newman installed and running, the next step is generating detailed reports from those collection runs.

Useful Options for Everyday Runs

The basic run command is just the start. A few flags cover most real needs.

# Run with an environment and a globals file
newman run collection.json -e staging.json -g globals.json

# Run only one folder inside the collection
newman run collection.json --folder "Login APIs"

# Repeat the collection 5 times
newman run collection.json -n 5

# Feed rows from a CSV file into each iteration
newman run collection.json -d users.csv

# Override a single environment variable from the command line
newman run collection.json -e staging.json --env-var "baseUrl=https://qa.example.com"

# Pause between requests and fail fast on the first error
newman run collection.json --delay-request 200 --bail

When you pass a data file, each row becomes one iteration, and column names become variables you can use as {{username}} in requests and scripts.

Running a Collection Straight from Postman

Exporting JSON files works, but files can go stale as people edit the collection in the app. Newman can also fetch a collection through the Postman API using a URL that includes your API key. Keep that key out of your code: store it as a secret in your CI tool and read it from an environment variable.

Newman Inside a Node.js Script

Newman is also a library, so you can start runs from JavaScript and react to the results.

const newman = require("newman");

newman.run({
  collection: require("./collection.json"),
  environment: require("./staging.json"),
  reporters: "cli"
}, (err, summary) => {
  if (err) { throw err; }
  const failures = summary.run.failures.length;
  console.log(`Finished with ${failures} failure(s)`);
  process.exitCode = failures > 0 ? 1 : 0;
});

How Exit Codes Help Automation

Newman exits with code 0 when every request and test passes and a non-zero code when something fails. CI tools such as Jenkins, GitHub Actions and GitLab CI read that code to mark the build as failed. That is why a Newman step can act as an automatic quality gate after every deploy.

# Inside a CI job
npm install -g newman
newman run tests/collection.json -e tests/ci.json

Troubleshooting Checklist

  • "newman: command not found": the global npm folder is not on your PATH, or install with npx newman instead.
  • Variables are empty: the environment file was not passed, or the variable names differ in case.
  • Works in Postman, fails in Newman: check for values saved only as "current value", which are not exported.
  • SSL errors on internal test servers: configure the proper CA certificate with --ssl-extra-ca-certs rather than turning certificate checks off.
  • Local files not found: use --working-dir so file uploads resolve correctly.

Keeping Versions Consistent Across Machines

A global install is fine on your own laptop, but different team members and CI servers can end up with different Newman versions. A safer option is to add Newman as a development dependency of a small Node.js project inside your test repository with npm install --save-dev newman, and run it through an npm script. The lock file then pins the exact version everyone uses, and new joiners only need npm ci to get started. Check periodically that your Node.js version is still supported by the Newman release you use.

Ready to master Postman API Testing Course?

Join Uncodemy's hands-on training and build real-world API testing skills with expert mentors.

Explore Course