1.0.0 • Published 9 years ago

promisify-supertest v1.0.0

Weekly downloads
38
License
MIT
Repository
github
Last release
9 years ago

promisify-supertest


npm version Build Status Dependency Status devDependency Status peerDependency Status

SuperTest + Promises. Uses native promises instead of bluebird.


Installation:

npm i -D promisify-supertest

Usage

It's a drop-in replacement for SuperTest

var request = require('promisify-supertest'); 

Also, it modifies the main supertest module handy with ES2015:

import 'promisify-supertest';
import request from 'supertest'; // Still promisified.

Then, just omit a callback, and it returnes a promise

request(app)
	.get('/')
	.end()
	.then(function(res) { // blah blah blah })
	.catch(function(err) { throw err; });

// But this still works too:
request(app)
	.get('/')
	.end(function(err, res) {
		if (err) throw err;
		// blah blah blah
	});

Contributing

PR's welcome!

Check in the issue tracker for issues, then file a fix one of them and send a PR!

Please make sure to have your code comply with standard (I know, but it was easy):

npm run lint

License

MIT: http://ariporad.mit-license.org