Skip to content

Chai plugin to assert on Postman Collections

License

Notifications You must be signed in to change notification settings

postmanlabs/chai-postman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4d30234 · Apr 25, 2021
Apr 25, 2021
Oct 5, 2020
Apr 25, 2021
Apr 23, 2021
Oct 5, 2020
Oct 5, 2020
Oct 5, 2020
Oct 5, 2020
Oct 5, 2020
Oct 5, 2020
Apr 25, 2021
Apr 25, 2021
Oct 11, 2017
Oct 5, 2020
Dec 12, 2019
Oct 11, 2017
Apr 25, 2021
Apr 25, 2021

Repository files navigation

chai-postman Build Status codecov

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.