Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including chai-postman with all npm packages installed. Try it out:

var chaiPostman = require("chai-postman")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

chai-postman v1.1.3

A Chai plugin for Postman assertions

chai-postman

Greenkeeper badge Chai plugin to assert on Postman Collections

Install

$ npm install chai-postman --save-dev

Usage

In order to use this plugin, ensure that you have postman-collection and lodash installed.

var _ = require('lodash'),
    chai = require('chai'),
    sdk = require('postman-collection'),
    chaiPostman = require('chai-postman'),

    req,
    res,
    expect = chai.expect;

chai.use(chaiPostman(sdk, _));

// create postman-collection request and response instances
req = new sdk.Request({
    header: [{
        key: 'Content-Type',
        value: 'application/json; charset=utf-8'
    }]
});
res = new sdk.Response({ code: 200 });

// request assertions
expect(req).to.be.a.postmanRequest;
expect(req).to.have.header('Content-Type'); // an optional second argument can also be provided to assert value

// response assertions
expect(res).to.be.a.postmanResponse;
expect(res).to.have.statusCode(200);

Check the tests for a complete reference.

Compatibility

chai-postmanpostman-collectionlodash
v0.1.0v3.xv4.17.4
v1.0.0v3.xv4.17.4
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free