chai-postman Build Status codecov

Chai プラグインで Postman コレクションをアサート

インストール

$ npm install chai-postman --save-dev

使用方法

このプラグインを使用するには、postman-collectionlodash がインストールされていることを確認してください。

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);

完全なリファレンスについては、テスト を参照してください。