You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following up on our call today regarding testing real vs. fake http requests ...
I wouldn't say there's a one size fits all solution for this, but when you are making http requests to the internet in a package in a test, you aren't just testing your code, you're also testing the remote API. So some folks to better isolate and only test their own code (and not whether a remote API is up or down or changed) they use something (fakes, mocks, etc.) to prevent real http requests from being made.
There's a variety of options in the book. I'm most familiar with vcr and webmockr since I maintain them, and can help with those if you go that way.
Even if you do most of you tests without running real http requests, it's a good idea to have some real http requests in case the remote API changes - one way to do that with vcr by changing one env var VCR_TURN_OFF, which you could do on github actions or locally to ignore the fixtures and do real http requests
One caveat with this route is that you should be sure you're not including secrets in your test fixtures.
You could decide you do want real http requests for all your tests, and no changes needed! happy to chat more about this
The text was updated successfully, but these errors were encountered:
Thanks for this helpful explanation @sckott. @cansavvy I think we should definitely have some real http requests using vcr, and I can work on this down the road.
note that vcr helps you avoid real HTTP requests, but using that env var thing mentioned you can turn it off to make real HTTP requests. just clarifying in case there's any confusion.
Following up on our call today regarding testing real vs. fake http requests ...
I wouldn't say there's a one size fits all solution for this, but when you are making http requests to the internet in a package in a test, you aren't just testing your code, you're also testing the remote API. So some folks to better isolate and only test their own code (and not whether a remote API is up or down or changed) they use something (fakes, mocks, etc.) to prevent real http requests from being made.
There's a variety of options in the book. I'm most familiar with
vcr
andwebmockr
since I maintain them, and can help with those if you go that way.Even if you do most of you tests without running real http requests, it's a good idea to have some real http requests in case the remote API changes - one way to do that with
vcr
by changing one env varVCR_TURN_OFF
, which you could do on github actions or locally to ignore the fixtures and do real http requestsOne caveat with this route is that you should be sure you're not including secrets in your test fixtures.
You could decide you do want real http requests for all your tests, and no changes needed! happy to chat more about this
The text was updated successfully, but these errors were encountered: