3.1.3 • Published 2 years ago

@tmclnk/newman-reporter-json-stats v3.1.3

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
2 years ago

Newman JSON Stats Reporter

A reporter for newman, the command-line postman runner.

This reporter prints detailed statistics as json, including detailed breakdowns of timings like you get from the cli reporter. This includes dns lookup, tcp and ssl handshake times, download time, and processing time.

Getting Started

You'll need npm.

Install newman and the @tmclnk/json-stats reporter.

npm i -g newman
npm i -g @tmclnk/newman-reporter-json-stats

Command Line Usage

Once the @tmclnk/newman-reporter-json-stats npm module is installed, it is referenced from newman as @tmclnk/json-stats.

newman run https://raw.githubusercontent.com/tmclnk/newman-reporter-json-stats/main/examples/postman_collection.json \
  --reporters @tmclnk/json-stats \
  --verbose

Note that the --verbose flag is REQUIRED.

Variables

Use --env-var "key=value" to pass variables to your collection. For example, postman_collection_env.json uses a {{baseUrl}} parameter to construct its urls.

env-screenshot

newman run https://raw.githubusercontent.com/tmclnk/newman-reporter-json-stats/main/examples/postman_collection_env.json \
  --reporters @tmclnk/json-stats \
  --env-var "baseUrl=https://www.google.com" \
  --verbose

Output

[
  {
    "url": "https://www.devobsessed.com/",
    "method": "GET",
    "requestSize": 231,
    "responseSize": 19548,
    "statusCode": 200,
    "timing": {
      "start": 1661614275544,
      "requestStart": 1661614275554,
      "offset": {
        "request": 10.167584002017975,
        "socket": 13.681499987840652,
        "lookup": 15.907375007867813,
        "connect": 37.22204199433327,
        "secureConnect": 73.76374998688698,
        "response": 134.60854199528694,
        "end": 142.72445899248123,
        "done": 147.13712498545647
      },
      "phases": {
        "prepare": 10.167584002017975,
        "wait": 3.5139159858226776,
        "dns": 2.2258750200271606,
        "tcp": 21.314666986465454,
        "firstByte": 60.84479200839996,
        "download": 8.11591699719429,
        "process": 4.412665992975235,
        "total": 147.13712498545647,
        "secureHandshake": 36.54170799255371
      }
    }
  }
]

Units are milliseconds, bytes, or epoch milliseconds.

  • timing.offset is milliseconds from the start of the request
  • timing.phases is milliseconds of each phase

Library Usage

You can use this newman and this module as a library. This might be useful if you want to roll a standalone app with simplified syntax or baked-in collections.

See example.js.

const newman = require("newman");

newman.run(
    {
        collection: require("./postman_collection_env.json"),
        reporters: "@tmclnk/json-stats",
        envVar: [{ key: "baseUrl", value: "https://www.google.com" }],
        verbose: true, // required to get newman to generate add'l statistics
        silent: true, // don't let the reporter write to stdout
    },
    function (err, summary) {
        // your code here!
        console.log(summary.statistics);
    }
);

Troubleshooting

newman: could not find "@tmclnk/json-stats" reporter
ensure that the reporter is installed in the same directory as newman
please install reporter using npm

If you get the above error, and you installed newman using a package manager (brew, apt, yum, chocolatey), you may need to uninstall newman and re-install using npm.

npm i -g newman

Related Links

3.1.3

2 years ago

3.1.2

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.1

2 years ago