Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Migrate away from supertest #54

Open
nickserv opened this issue Sep 7, 2017 · 3 comments
Open

Migrate away from supertest #54

nickserv opened this issue Sep 7, 2017 · 3 comments

Comments

@nickserv
Copy link
Member

nickserv commented Sep 7, 2017

Now that we're using Jest, we can use Promise returns, async/await, and the .resolves and .rejects matchers instead of using the expectations coupled with supertest (which I have a feeling don't fully support Jest's logging the way that the built in matchers do).

Node HTTP clients using Promises

  • util.promisify(http.request) (Node 8 or the util.promisify shim package)
  • node-fetch (implementation of fetch for Node)
  • axios
  • r2
  • request-promise
@nickserv nickserv mentioned this issue Sep 7, 2017
9 tasks
@nickserv
Copy link
Member Author

nickserv commented Sep 9, 2017

I tried to start this in #55, turns out it's a lot of work because we're coupled with how supertest can make requests against servers and callbacks. While Jest makes async expectations easy, we'd have to refactor all the tests to manually open and close servers or use a custom request utility that does this. The latter approach seems to be working so far but I'm going to take a break from this since it involves so much work migrating tests.

This may or may not be worth it. I don't like coupling the way we make requests to the way we make expectations about them because it makes it difficult to use Jest's awesome async matchers. But it may be more work than it's worth for now.

@jonathanong
Copy link
Member

btw supertest returns promises now

@nickserv
Copy link
Member Author

Thanks, I'm aware of that, I actually used it in some in progress code for migrating away from supertest. However, Jest has resolves and rejects matchers and async/await support (and Babel support if you're testing on a Node version that doesn't have it natively). I'd rather stick to Jest's built in matchers for their improved error messages and framework integrations. We could also just switch from supertest to superagent, though we unfortunately lose the ability to pass a server to the initial request function.

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

No branches or pull requests

2 participants