Skip to content

pactumjs/pactum-swagger-coverage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pactum-swagger-coverage

Build Downloads Size Platform

JSON swagger/openapi3 coverage reporter for Pactum tests. It's capable of reading the swagger/oas3 definitions from either swagger.yaml or swagger.json or openapi3.yaml (served on a http server endpoint).

Installation

npm install --save-dev pactum pactum-swagger-coverage

Usage

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

// global before block
before(() => {
  reporter.add(psc);
});

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

Reporter Options

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

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

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

/** 
* base path - defaults to `basePath` for swagger 2.0/openapi2 and first server url 
* or empty if either of them doesn't exist or not set explicitly
*/ 
psc.basePath = '/api/server/v1'; 

// Swagger json url of the server - defaults to ""
psc.swaggerJsonUrl = "http://localhost:3010/api/server/v1/json";

// Swagger Yaml file path - defaults to ""
psc.swaggerYamlPath = './tests/testObjects/swagger.yaml';

Report Json Output (example)

{
  "basePath": "/api/server/v1",
  "coverage": 0.2,
  "coveredApiCount": 1,
  "missedApiCount": 4,
  "totalApiCount": 5,
  "coveredApiList": [
    "/getallninjas"
  ],
  "missedApiList": [
    "/health",
    "/getninjabyid/{id}",
    "/getninjabyname/{name}",
    "/getninjabyrank/{rank}"
  ]
}

Note: Either 'swaggerJsonUrl' or 'swaggerYamlPath' should be provided for reporter to work.

Notes

Read more about Pactum here.

Inspired by swagger-coverage-postman.


API Testing

About

JSON swagger coverage reporter for Pactum tests

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy