npm.io
2.4.1 • Published 3 weeks ago

newman-reporter-qase

Licence
Apache-2.0
Version
2.4.1
Deps
2
Size
6.4 MB
Vulns
0
Weekly
0
Stars
60

Qase TestOps Newman Reporter

License npm downloads

Qase Newman Reporter enables seamless integration between your Newman/Postman collection tests and Qase TestOps, providing automatic test result reporting, test case management, and comprehensive test analytics.

Features

  • Link automated tests to Qase test cases by ID using special comments
  • Auto-create test cases from your Postman test scripts
  • Report test results with parameterized data
  • Multi-project reporting support
  • Flexible configuration (file, environment variables)

Note: Newman integration is unique - tests are defined in Postman collections, and Qase IDs are specified via special comments in test scripts, not via programmatic API imports.

Installation

npm install --save-dev newman-reporter-qase

Quick Start

1. Create qase.config.json in your project root:

{
  "mode": "testops",
  "testops": {
    "project": "YOUR_PROJECT_CODE",
    "api": {
      "token": "YOUR_API_TOKEN",
      "host": "qase.io"
    }
  }
}

If your workspace is on the EU cluster (you open Qase at app-eu.qase.io), set host to eu.qase.io. The default, qase.io, is the US cluster.

2. Add Qase ID to your Postman test using special comments:

In your Postman collection test script:

// qase: 1
pm.test('Response status is 200', function() {
  pm.response.to.have.status(200);
});

3. Run your Newman tests with Qase reporter:

QASE_MODE=testops newman run ./collection.json -r qase

Configuration

The reporter is configured via (in order of priority):

  1. Environment variables (QASE_*)
  2. Config file (qase.config.json)
Minimal Configuration
Option Environment Variable Description
mode QASE_MODE Set to testops to enable reporting
testops.project QASE_TESTOPS_PROJECT Your Qase project code
testops.api.token QASE_TESTOPS_API_TOKEN Your Qase API token
testops.api.host QASE_TESTOPS_API_HOST qase.io (US cluster, the default) or eu.qase.io (EU cluster). Required if your workspace is on the EU cluster
Example qase.config.json
{
  "mode": "testops",
  "fallback": "report",
  "testops": {
    "project": "YOUR_PROJECT_CODE",
    "api": {
      "token": "YOUR_API_TOKEN",
      "host": "qase.io"
    },
    "run": {
      "title": "Newman Automated Run"
    },
    "batch": {
      "size": 100
    }
  },
  "report": {
    "driver": "local",
    "connection": {
      "local": {
        "path": "./build/qase-report",
        "format": "json"
      }
    }
  }
}

Full configuration reference: See qase-javascript-commons for all available options including logging, status mapping, execution plans, and more.

Usage

Associate your Postman tests with Qase test cases using special comments in your test scripts:

Single ID:

// qase: 10
pm.test('Response is successful', function() {
  pm.response.to.be.info;
});

Multiple IDs:

// Qase: 1, 2, 3
pm.test('Verify user data', function() {
  pm.expect(pm.response.json()).to.have.property('user');
});

Alternative formats:

// qase: 4 5 6 14
pm.test('Check multiple conditions', function() {
  pm.response.to.have.status(200);
});

Important: The comment must be on the line immediately before the pm.test() call.

Add Parameters

Newman supports parameterized tests when using data files. Specify which parameters to report using special comments:

// qase.parameters: userId, user.name
pm.test('User ID is correct', function() {
  var jsonData = pm.response.json();
  pm.expect(jsonData.userId).to.eql(pm.iterationData.get('userid'));
});

You can also specify parameters at the collection or folder level:

{
  "item": [{
    "name": "Folder Name",
    "event": [{
      "listen": "test",
      "script": {
        "exec": [
          "// qase.parameters: userId, user.name"
        ]
      }
    }]
  }]
}
Auto-collect All Parameters

To automatically report all parameters from data files without specifying them:

{
  "framework": {
    "newman": {
      "autoCollectParams": true
    }
  }
}
Ignore Tests

Newman does not support ignoring individual tests. All tests in the collection will be executed and reported (unless filtered by Newman's own mechanisms like --folder flag).

Test Result Statuses
Newman Result Qase Status
Passed passed
Failed failed
Skipped (pm.execution.skipRequest()) skipped
Script or request error invalid

For more usage examples, see the Usage Guide.

Running Tests

Basic Execution with CLI
# Run with Qase reporter
QASE_MODE=testops newman run ./collection.json -r qase

# Run with multiple reporters
QASE_MODE=testops newman run ./collection.json -r cli,qase

# Run specific folder
QASE_MODE=testops newman run ./collection.json -r qase --folder "API Tests"
Using Data Files
# Run with JSON data file
newman run ./collection.json -r qase -d ./data.json

# Run with CSV data file
newman run ./collection.json -r qase -d ./users.csv
Using Environment Variables
# Set environment variables
newman run ./collection.json -r qase -e ./environment.json

# Override config with environment variables (set QASE_TESTOPS_API_HOST to eu.qase.io on the EU cluster)
QASE_MODE=testops \
QASE_TESTOPS_PROJECT=DEMO \
QASE_TESTOPS_API_TOKEN=your_token \
QASE_TESTOPS_API_HOST=qase.io \
newman run ./collection.json -r qase
Programmatic Usage
const newman = require('newman');

newman.run({
  collection: require('./collection.json'),
  reporters: ['qase'],
  reporter: {
    qase: {
      // Reporter options can be passed here
      // But prefer using qase.config.json for consistency
    }
  }
}, function(err) {
  if (err) { throw err; }
  console.log('Collection run complete');
});

Requirements

  • Node.js >= 14
  • Newman >= 5.3.0

Documentation

Guide Description
Usage Guide Complete usage reference with parameters and examples
Attachments Adding screenshots, logs, and files to test results
Steps Defining test steps for detailed reporting
Multi-Project Support Reporting to multiple Qase projects
Upgrade Guide Migration guide for breaking changes
Configuration Reference Full configuration options

Examples

See the examples directory for complete working examples.

License

Apache License 2.0. See LICENSE for details.