# supertest-test2doc

> A supertest extension to make life easier with test2doc.js

Latest version **0.1.1** (published 2017-03-09) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-03-09 |
| First published | 2017-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Stackia |
| Maintainers | stackia |
| Keywords | test2doc, supertest, docs, api, test, documents |

## Links

- npm: https://www.npmjs.com/package/supertest-test2doc
- Repository: https://github.com/stackia/supertest-test2doc
- Homepage: https://github.com/stackia/supertest-test2doc#readme
- Issues: https://github.com/stackia/supertest-test2doc/issues
- npm.io page: https://npm.io/package/supertest-test2doc

## Dependencies (1)

- [methods](https://npm.io/package/methods.md) ^1.1.2

## 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
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-03-09
- 0.1.0 — 2017-03-09

## README

# supertest-test2doc

A [supertest](https://github.com/visionmedia/supertest) extension to make life easier with [test2doc.js](https://github.com/stackia/test2doc.js).

## Usage

```
npm install --save-dev supertest test2doc supertest-test2doc
```

Simple use `const request = require('supertest-test2doc')(require('supertest'))` and `request(app).with(doc)` and then you no longer need to write `doc.get/post/put/delete/query/resBody...`.

E.g.

```javascript
const doc = require('test2doc')
const request = require('supertest-test2doc')(require('supertest'))
require('should')

// For Koa, you should exports app.listen() or app.callback() in your app entry
const app = require('./my-express-app.js')

after(function () {
  doc.emit('api-documentation.apib') // Or doc.emit('api-documentation.yaml', 'swagger') if you like Swagger
})

doc.group('Products').is(doc => {
  describe('#Products', function () {
    doc.action('Get all products').is(doc => {
      it('should get all products', function () {
        return request(app).with(doc)
          .get('/products')
          .query({
            minPrice: doc.val(10, 'Only products of which price >= this value should be returned').required()
          })
          .expect(200)
          .then(res => {
            res.body.desc('List of all products')
              .should.not.be.empty()
            res.body[0].should.have.properties('id', 'name', 'price')
            res.body[0].price.desc('Price of this product').should.be.a.Number()
          })
      })
    })
  })
})
```

You can find more examples [here](https://github.com/stackia/supertest-test2doc/blob/master/example/v2ex/v2ex.js).

## License

The project is released under [MIT License](https://github.com/stackia/test2doc.js/blob/master/LICENSE).

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