https://github.com/stackia/supertest-test2doc
A supertest extension to make life easier with test2doc.js.
https://github.com/stackia/supertest-test2doc
documentation-tool javascript supertest test2doc testing
Last synced: 27 days ago
JSON representation
A supertest extension to make life easier with test2doc.js.
- Host: GitHub
- URL: https://github.com/stackia/supertest-test2doc
- Owner: stackia
- License: mit
- Created: 2017-03-09T06:06:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T18:22:20.000Z (over 5 years ago)
- Last Synced: 2025-04-03T08:36:59.639Z (6 months ago)
- Topics: documentation-tool, javascript, supertest, test2doc, testing
- Language: API Blueprint
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# supertest-test2doc
[](https://www.npmjs.com/package/supertest-test2doc) [](https://www.npmjs.com/package/supertest-test2doc) [](https://travis-ci.org/stackia/supertest-test2doc) [](https://david-dm.org/stackia/supertest-test2doc) [](https://david-dm.org/stackia/supertest-test2doc?type=dev) [](https://gitter.im/test2doc-js/Lobby)
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).