Skip to content

API Coverage Reporter for Pactum. Provides operation & response level coverage and supports JSON schemas for swagger/OAS specs.

License

Notifications You must be signed in to change notification settings

honzabit/pactum-api-coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pactum-api-coverage

Platform

API coverage reporter for Pactum tests. Accepts Swagger/OAS spec data in JSON format.

Installation

npm install --save-dev pactum pactum-api-coverage

Usage

const pactum = require('pactum');
const psc = require('pactum-api-coverage');
const reporter = pactum.reporter;

// global before block
before(() => {
  psc.specData = require("./specs/v1/oas.json");
  reporter.add(psc);
});

// global after block
after(() => {
  return reporter.end();
});

Reporter Options

const psc = require('pactum-api-coverage');

// name of the report file - defaults to "api-cov-report.json"
psc.file = 'report-name.json';

// folder path for the report file - defaults to "./reports"
psc.path = './reports-path';

// Load a local JSON spec file (or a remote one)
psc.specData = require("./specs/v1/oas.json");

// Ignore specific response codes
psc.ignoreResponseCodes = [ 429, 500]

Report Json Output (example)

{
  "basePath": "/v1",
  "coverage": 0.5,
  "coveredApiCount": 4,
  "missedApiCount": 4,
  "totalApiCount": 8,
  "coveredApiList": [
    "200|get|/v1/health",
    "200|get|/v1/getallninjas",
    "200|get|/v1/getninjas/{rank}",
    "200|get|/v1/getninja/{rank}/{name}"
  ],
  "missedApiList": [
    "200|post|/v1/health",
    "200|get|/v1/getninjas/{clan}/{rank}",
    "400|get|/v1/getninjas/{clan}/{rank}",
    "200|get|/v1/getninja/{name}"
  ]
}

Notes

Read more about Pactum here.

Copied from pactum-swagger-coverage and altered.

About

API Coverage Reporter for Pactum. Provides operation & response level coverage and supports JSON schemas for swagger/OAS specs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published