Skip to content

Commit 63ec2b7

Browse files
author
ChaiJs Bot
committed
(data): Auto build _data
1 parent 2ccc31a commit 63ec2b7

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

_data/plugin_keywords.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@
437437
"plugins": [
438438
"plugins"
439439
],
440+
"postman": [
441+
"postman"
442+
],
440443
"precision": [
441444
"precision"
442445
],

_data/plugins/chai_postman.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

plugins/chai_postman.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.

0 commit comments

Comments
 (0)