Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise wrapper method #21

Closed
JustinLivi opened this issue Aug 8, 2016 · 2 comments
Closed

Promise wrapper method #21

JustinLivi opened this issue Aug 8, 2016 · 2 comments

Comments

@JustinLivi
Copy link

Would you be open to a PR that adds a mongoose-style exec method?

Usage would look like this:

supertest( app )
.get( '/someRoute' )
.expect( 200 )
// wraps supertest.end in a promise
.exec()
.then( function() {
    // success
})
.catch( function( error ) {
    // failure
});
@rjz
Copy link
Owner

rjz commented Aug 8, 2016

Hey, @JustinLivi! We could do this, but there might be other approaches. @benesch has a promise-based supertest extension in supertest-as-promised that @shaunc previously wrapped—would something like that suit your needs?

If the exec/thunk makes better sense for the use-case, it may be better to follow the pattern of extending this package externally rather than changing the API here. This library has mirrored supertest's continuation-passing API fairly closely (in fact, improving agent support in 'recent' supertest versions has largely mooted this library's raison d'etre), and departing from it may complicate future compatibility changes.

That being said, I'd be very happy to see this extension working in some form!

@JustinLivi
Copy link
Author

I wasn't aware of the existence of either of these modules. supertest-session-as-promised looks exactly like what I need, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants