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

What do you want to test? #39

Open
sckott opened this issue Dec 4, 2023 · 4 comments
Open

What do you want to test? #39

sckott opened this issue Dec 4, 2023 · 4 comments
Assignees

Comments

@sckott
Copy link

sckott commented Dec 4, 2023

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

@howardbaik
Copy link
Contributor

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.

@cansavvy
Copy link
Collaborator

cansavvy commented Dec 5, 2023

Yes for sure! I wanna make all the testing more specific and robust! So this is great. Thanks for writing this down, @sckott !

@sckott
Copy link
Author

sckott commented Dec 5, 2023

@howardbaek

have some real http requests using vcr

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.

@howardbaik
Copy link
Contributor

Thanks @sckott . I'll let you know if I have any further questions once I drive deeper.

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

3 participants