https://github.com/jameskyburz/test-listen-destroy
http server for tests with single assertion per call.
https://github.com/jameskyburz/test-listen-destroy
http nodejs test
Last synced: 2 months ago
JSON representation
http server for tests with single assertion per call.
- Host: GitHub
- URL: https://github.com/jameskyburz/test-listen-destroy
- Owner: JamesKyburz
- License: apache-2.0
- Created: 2017-06-07T07:27:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:33:53.000Z (about 5 years ago)
- Last Synced: 2025-03-13T09:48:10.433Z (over 1 year ago)
- Topics: http, nodejs, test
- Language: JavaScript
- Homepage: https://npm.im/test-listen-destroy
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# test-listen-destroy
Uses [test-listen](https://npm.im/test-listen) but destroys http server when request is done.
This allows a single assertion per call.
[](https://github.com/feross/standard)
[](https://npmjs.org/package/test-listen-destroy)
[](https://greenkeeper.io/)
# example
```javascript
const listen = require('./')
const test = require('tape')
const request = require('request-promise')
test('server', async (t) => {
t.plan(1)
const fn = (req, res) => res.end('hello')
const url = await listen(fn)
const res = await request(url)
t.deepEqual(res, 'hello', 'server returns hello')
})
```
# license
[Apache License, Version 2.0](LICENSE)