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-reporter-integration

v1.1.1

Published

Json reporter based on Suits and tests for Integration testing

Downloads

757

Readme

Newman Integration Reporter

A integration reporter for Newman that formats and outputs test execution results grouped by suites, allowing for better insights into your Postman collection runs.

Table of Contents

Installation

You can install the integration reporter globally using npm:

npm install -g newman-reporter-integration

Usage

To use the integration reporter with Newman, run your collection with the following command:

newman run <path_to_collection> -r integration --reporter-integration-outputPath=\"<path_to_output_file>\"

Options

  • <path_to_collection>: Path to your Postman collection file (e.g., .json).
  • -r integration: Specify the integration reporter.
  • --reporter-integration-outputPath: Specify the output path for the report file (e.g., ../results/report.json).

Events

This reporter listens for several Newman events. Here are the main ones:

  • request: Triggered after a request is completed, where you can access the request and response data.
  • done: Triggered when the run is finished, providing final results and summary.

Example

Here is a complete example of how to run a Postman collection using Newman with the integration reporter:

newman run /path/to/your/collection.json -r integration --reporter-integration-outputPath=\"../results/report.json\"

This command will execute the collection located at /path/to/your/collection.json and output the formatted results to ../results/report.json.

Integration Reporter Code Structure

The integration reporter code should be structured as follows:

function integrationNewmanReporter(emitter, options, collectionRunOptions) {
    // Your reporter implementation goes here.
}
module.exports = integrationNewmanReporter;

Make sure to handle different Newman events appropriately to gather and format the results you need.

Use Case

This integration reporter is particularly useful in CI/CD pipelines where you want to monitor the health of your APIs during integration tests. By grouping results by suites, it becomes easier to identify failing tests, which can be attributed to specific API endpoints or functionalities.

Example Scenario

Imagine you have a Postman collection that includes various suites like Health, Status, and User Management. Each suite contains requests to check the health of your services and verify status codes. When you run your collection, the integration reporter will:

  1. Group the results by suite.
  2. Provide clear visibility into which suite and requests are failing.
  3. Output a JSON file that can be used for further analysis or reporting in your CI/CD system.

JSON Example

{
  "run": {
    "collection": {
      "name": "Example PR Tests",
      "id": "your-collection-id",
      "info": {
        "description": "Collection for Example API tests"
      }
    },
    "executions": [
      {
        "suite": "Health",
        "requests": [
          {
            "name": "Get Token",
            "status": "passed",
            "statusCode": 200,
            "responseTime": 120,
            "response": {
              "body": {
                "token": "your_token_here"
              }
            },
            "error": null
          },
          {
            "name": "Health Check",
            "status": "failed",
            "statusCode": 500,
            "responseTime": 150,
            "response": null,
            "error": "Internal Server Error"
          }
        ]
      },
      {
        "suite": "Status",
        "requests": [
          {
            "name": "Check Service Status",
            "status": "passed",
            "statusCode": 200,
            "responseTime": 80,
            "response": {
              "body": {
                "status": "OK"
              }
            },
            "error": null
          },
          {
            "name": "Check Queue Status",
            "status": "passed",
            "statusCode": 200,
            "responseTime": 95,
            "response": {
              "body": {
                "queueStatus": "Active"
              }
            },
            "error": null
          }
        ]
      }
    ]
  },
  "summary": {
    "totalRequests": 4,
    "totalPassed": 3,
    "totalFailed": 1,
    "duration": 450
  }
}

License

This project is licensed under the MIT License.