promisify-supertest
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/promisify-supertest package

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i promisify-supertest

Weekly Downloads

27

Version

1.0.0

License

MIT

Last publish

Collaborators

  • ariporad