# supertest-rest

> supertest-rest is http api test framework and base on supertest, especially for REST architectural api

Latest version **1.0.3** (published 2015-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install supertest-rest
pnpm add supertest-rest
yarn add supertest-rest
bun add supertest-rest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2015-06-04 |
| First published | 2015-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hcnode |
| Maintainers | hcnode |
| Keywords | supertest, mocha |

## Links

- npm: https://www.npmjs.com/package/supertest-rest
- Repository: https://github.com/hcnode/supertest-rest
- Issues: https://github.com/hcnode/supertest-rest/issues
- npm.io page: https://npm.io/package/supertest-rest

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^3.9.3
- [supertest](https://npm.io/package/supertest.md) ^1.0.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2015-06-04
- 1.0.2 — 2015-06-04
- 1.0.1 — 2015-06-04
- 1.0.0 — 2015-06-04

## README

**About**

 supertest-rest is http api test framework and base on supertest, especially for REST architectural api

**Install**

    npm install supertest-rest

**Test**

    mocha
  
**Example**

[test/test.js](https://github.com/hcnode/supertest-rest/blob/master/test/test.js)

**Usage**

make a config object for some setting and test cases

    {
		// you can define endPoint or make your owner custom supertest request as well
		endPoint :   // base url of api
		getReqeust : // custom supertest
		testCases : // Array of test case object
    }

test cases object can be like sample bellow:

    {
			name: "updatePets1",
			put: "/pets/{{id}}",
			params: {
				name : "new name"
			},
			assert : function (res) {
				assert.equal(res.body.name, "new name");
			},
			bindId : ["addPets1"]
		}

 - name : name of the test case
 - put : the key is method of http request, value is the path of the api
 - body : the body of the request when the method is post or put
 - assert : the function will be called after receive the response, you can put some assert codes here to assert the body or header in the response object as you expected
 - bindId : Array of the other test cases name, which provide the id that will be replace the "{{id}}" in this case's path, and the id is obtained from the response object that from bindId's test case

**中文说明**


 - name : 测试用例的名称
 - put ： key是http请求的method，值是请求的path
 - body ：post或者put请求的body
 - assert：http请求返回后的调用，传入的res参数，可以在assert语句中判断body或者header是否符合预期
 - bindId：其他测试用例的name，用来替换path中的id，通常是在其他测试用例的response body里面获取的id属性

---
_Source: https://npm.io/package/supertest-rest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
