File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 437437 "plugins" : [
438438 " plugins"
439439 ],
440+ "postman" : [
441+ " postman"
442+ ],
440443 "precision" : [
441444 " precision"
442445 ],
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ ---
2+ layout : plugin
3+ permalink : plugins/chai-postman/
4+ pluginName : chai-postman
5+ ---
6+
7+ # chai-postman [ ![ Build Status] ( https://travis-ci.com/postmanlabs/chai-postman.svg?branch=develop )] ( https://travis-ci.com/postmanlabs/chai-postman ) [ ![ codecov] ( https://codecov.io/gh/postmanlabs/chai-postman/branch/develop/graph/badge.svg )] ( https://codecov.io/gh/postmanlabs/chai-postman )
8+
9+ [ Chai plugin] ( http://chaijs.com/api/plugins/ ) to assert on Postman Collections
10+
11+ ## Install
12+ ``` bash
13+ $ npm install chai-postman --save-dev
14+ ```
15+
16+ ## Usage
17+ In order to use this plugin, ensure that you have [ postman-collection] ( https://www.npmjs.com/package/postman-collection )
18+ and [ lodash] ( https://www.npmjs.com/package/lodash ) installed.
19+
20+ ``` javascript
21+ var _ = require (' lodash' ),
22+ chai = require (' chai' ),
23+ sdk = require (' postman-collection' ),
24+ chaiPostman = require (' chai-postman' ),
25+
26+ req,
27+ res,
28+ expect = chai .expect ;
29+
30+ chai .use (chaiPostman (sdk, _));
31+
32+ // create postman-collection request and response instances
33+ req = new sdk.Request ({
34+ header: [{
35+ key: ' Content-Type' ,
36+ value: ' application/json; charset=utf-8'
37+ }]
38+ });
39+ res = new sdk.Response ({ code: 200 });
40+
41+ // request assertions
42+ expect (req).to .be .a .postmanRequest ;
43+ expect (req).to .have .header (' Content-Type' ); // an optional second argument can also be provided to assert value
44+
45+ // response assertions
46+ expect (res).to .be .a .postmanResponse ;
47+ expect (res).to .have .statusCode (200 );
48+ ```
49+
50+ Check the [ tests] ( https://github.com/postmanlabs/chai-postman/tree/develop/test/unit ) for a complete reference.
You can’t perform that action at this time.
0 commit comments