top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

Deprecation warning : punycode module is deprecated on node.js v22.1.0 and deep dive into Newman command options

Postman is a widely-used tool that helps to build, test and modify APIs. One of its key features is the ability to write and execute tests for APIs. While Postman provides an intuitive interface for test creation and execution, it’s often necessary to run tests in an automated fashion and generate detailed reports for test runs. This is where Newman, the command-line companion for Postman, comes into play.


In this blog we will explore on how to resolve the dependency issue of punycode module in node.js to generate a Newman report. We will explore on Newman "run" command and the options it provides to generate a customizable report, look into an example of how to handle iterations and how to read a data from csv file for a post request.


While generating a Newman report on mac for the exported postman collections on node.js V22.1.0, faced the deprecation warning error which says punycode module is deprecated on node.js V22.1.0, as shown in the below screenshot:



Let's see what is punycode module and does it play significant role for generating Newman report for our postman collection?

Punycode is character encoding scheme defined by RFC 3492 that is primarily intended for use in International Domain Names. As the host names in URL are limited to ASCII characters only, so the domain names that contain non-ASCII characters must be converted into ASCII using the Punycode scheme. For instance if there is any domain name which is in specific language like Japanese, Hindi or any other language, the Internationalized Domain Name is represented by Punycode as the ASCII string. In simple words for our understanding let's put it as punycode module is simply for conversion of domain name to ASCII ,but yes the module does lot more.


Here in our postman collection our URL has a domain name in English, hence deprecation warning of punycode can be overcome by following below steps to produce a Newman report for our collection:


  1. Downgrading from node version 22.x to 20.10.0, here is the command:

nvm install 20.10.0

2 . Now we have to use the nvm installed in the above step by running the command mentioned below, so that we use the version 20.10.0 to generate the Newman report:


nvm use 20.10.0

3. Now we got to install Newman for the current version of node, run the command :

npm install -g newman


4. To generate the Newman html report we got to install Newman html reporter using the command "

npm install -g newman-reporter-htmlextra

5. All the required installations are completed to generate a Newman report. Let's run our postman collections to generate a Newman cli and Newman html report. Following are the commands to run for generating these reports:

newman run finalUserAPI.postman_collection.json

newman run finalUserAPI.postman_collection.json -r htmlextra 

Below is the screenshot of successful execution :


Hoping on to next part of the blog, Newman command options. Newman provides wide set of options to customize the collection run. Here is the syntax for newman usage:


newman [options] [command]

Newman provides two basic options as mentioned in below table and screen shot.


Option

Details

-h, --help

Output usage information

-v, --version

Output the version number

Where as Newman comes with single command "run".

Newman command "run" comes with other options. To get available options for a command use:

"newman <command> -help"

Example: newman run -help

The run command comes with following options, which can be specified with run command to generate desired output.

 -e, --environment <path>              

Specify a URL or path to a Postman Environment

  -g, --globals <path>                 

 Specify a URL or path to a file containing Postman Globals

  -r, --reporters [reporters]          

 Specify the reporters to use for this run (default: ["cli"])

  -n, --iteration-count <n>             

Define the number of iterations to run

  -d, --iteration-data <path>           

Specify a data file to use for iterations (either JSON or CSV)

  --folder <path>                       

Specify the folder to run from a collection. Can be specified multiple times to run multiple folders (default: [])

  --global-var <value>        

Allows the specification of global variables via the command line, in a     key=value format (default: [])

   --env-var <value> 

    Allows the specification of environment variables via the command line, in a key=value format (default: [])                         

  --export-environment <path>          

 Exports the final environment to a file after completing the run

  --export-globals <path>              

 Exports the final globals to a file after completing the run

  --export-collection <path>           

 Exports the executed collection to a file after completing the run

  --postman-api-key <apiKey>            

API Key used to load the resources from the Postman API

  --bail [modifiers]                    

Specify whether or not to gracefully stop a collection run on encountering an error and whether to end the run with an error based on the optional modifier

                                       


  --ignore-redirects                   

 Prevents Newman from automatically following 3XX redirect responses

  -x , --suppress-exit-code             

Specify whether or not to override the default exit code for the current run

  --silent                              

Prevents Newman from showing output to CLI

  --disable-unicode                     

Forces Unicode compliant symbols to be replaced by their plain text equivalents

  --color <value>                       

Enable/Disable colored output (auto|on|off) (default: "auto")

  --delay-request [n]                   

Specify the extent of delay between requests (milliseconds) (default: 0)

  --timeout [n]                         

Specify a timeout for collection run (milliseconds) (default: 0)

  --timeout-request [n]                 

Specify a timeout for requests (milliseconds) (default: 0)

  --timeout-script [n]                  

Specify a timeout for scripts (milliseconds) (default: 0)

  --working-dir <path>                  

Specify the path to the working directory

  --no-insecure-file-read               

Prevents reading the files situated outside of the working directory

  -k, --insecure                        

Disables SSL validations

  --ssl-client-cert-list <path>        

 Specify the path to a client certificates configurations (JSON)

  --ssl-client-cert <path>              

Specify the path to a client certificate (PEM)

  --ssl-client-key <path>               

Specify the path to a client certificate private key

  --ssl-client-passphrase <passphrase>  

Specify the client certificate passphrase (for protected key)

  --ssl-extra-ca-certs <path>           

Specify additionally trusted CA certificates (PEM)

  --cookie-jar <path>                   

Specify the path to a custom cookie jar (serialized tough-cookie JSON)

  --export-cookie-jar <path>           

 Exports the cookie jar to a file after completing the run

Usage of newman run command options plays a vital role to have a complete Newman html report.We can customize a collection run using Newman command options.

Lets see an example where we use run command option "-n" which defines the number of iterations the report must be generated for.

We will do a post request where the data for the post request body is been read from a csv file, here is the example post request body:

{
"user_first_name":"{{firstName}}",
"user_last_name":"{{lastName}}",
"user_contact_number":"{{contactNumber}}",
"user_email_id":"{{email}}",
}

Our csv file must contain the columns with same name as the postman variables, that is

column 1 in csv file must be "firstName",

column 2 in csv file must be "lastName",

column 3 in csv file must be "contactNumber",

column 4 in csv file must be "email"



As we see here we have 22 rows which go as input to our post request, thus we have 22 iterations as we see in postman run as shown below:




Now let's try to generate Newman cli and html report for this postman collection where we have our post request explained above with other request.


newman run finalUserAPI.postman_collection.json 



newman run finalUserAPI.postman_collection.json  -r htmlextra


We have 22 rows of data in our csv file and our postman collection run was for 22 iterations but the Newman reports got generated for only one iteration. Here where the use of Newman command options come into picture.

We can define the number of iterations the report must be generated for using the Newman run command option:

newman run -n 22 finalUserAPI.postman_collection.json

This gives the Newman cli report for 22 iterations as shown below:





And for the html report:

newman run -n 22 finalUserAPI.postman_collection.json -r htmlextra


This was an example for only one option of the Newman run command, likewise Newman provides wide range of options to customize the collection run and generate the report as per our requirement.


744 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page