tiagodavi
What do you guys think about using VCR to record/mock tests VS using tags to include/exclude external calls?
My team wants to use this library → GitHub - parroty/exvcr: HTTP request/response recording library for elixir, inspired by VCR. · GitHub
But I think it’s better to use tags as said here → Mocks and explicit contracts « Plataformatec Blog to include external calls as needed.
Does anyone have experience to talk about pros/cons ?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
blatyo
I’ve used both and would do so again. I’ve worked with complex multi-step API’s, where the tests were also acting as documentation for what the API accepted and returned and that the app was setup correctly to make them. In that situation, something like ExVCR is a godsend. It is possible to get stale cassettes, but it can still be useful to know that you didn’t introduce a regression with a known valid response. In most cases, I’d prefer using Mox, but that is explicitly not testing your integration with the API. So, you need to be sure you’re ok with that. Mox has the advantage that you can use
async: true, whereas most other things that do mocking usemeckand thus mock globally. It’s also much easier to use Mox on code you own. If you’ve build a client that wraps an API you own, it’s probably going to be pretty easy. If it’s someone else’s, it’s probably going to be much harder.blatyo
I just reread that article, it’s worth mentioning, it’s primarily talking about things that use your API client and having them not make the HTTP calls. However, if you want to test the client, you need to make the HTTP calls. It’s just suggesting that you do those things separately.
chulkilee
If you use behavior based mock, then you assume the client library behaves that way, and test your logic around the client library.
If you use exvcr, you test the behavior of the client library.
So it depends what you actually want to test.
blatyo
Just saw this as well: https://moosecode.nl/blog/introducing_walkman
I haven’t used it, but it uses a similar method to Mox in overriding so that async works.
fernandoalmeida
I believe VCR is an interesting tool in some scenarios and we need think
about its usage case by case.
I already had scenarios where we depended on several legacy internal APIs, for
example and the QA/test environment of these APIs where not reliable. In cases
like these I believe VCR brings a great value because it allows us to run
the tests isolated from the stability/instability of the QA/test environment
(that were out of our control, depending on other teams, etc).
Using tags, by default the tests are not executed and to execute them we
mandatorily depends on the environment. Using VCR this is optional, we can trust
that changing the API is an exception (not the rule) and we are able to run the
test really hitting the API or not.
In this case, during the development process we generally uses the VCR, because
the API probably was not changed between the first and the second running, but we
can run without it when we desire (during the development or in a CI, for
example).
So, given these benefits and flexibility (that have a big weight to me) I like so much this approach in these scenarios.