Open maxmarcon opened 1 year ago
This is a wild guess, but maybe try "clear mock" as mentioned in this issue: https://github.com/parroty/exvcr/issues/136 ?
Thanks. I tried but it doesn't work. And it makes sense: the tests are running concurrently, so clearing the mocks after a test doesn't guarantee in any way that another test running concurrently won't use the mocks
Discussed in elixirforum - https://elixirforum.com/t/approach-for-numerous-edge-cases-http-get-exvcr/50291/15?u=kanishka - probably resolved.
First of all, thanks for creating this library! I really want to use it as I feel it would allow me to write tests that interact with external APIs more efficiently than with my current approach.
What is my current approach? I use Bypass.
So right now I have a bunch of legacy tests for different REST APIs that use Bypass. My HTTP client is Tesla + Finch.
I wrote a test for a new API using ExVcr. When I run the ExVcr test asynchronously together with the other async Bypass-based tests, some of the Bypass tests always fail. Which tests exactly fail is random and depends on the order of execution I guess. If I run the ExVcr test with
async: false
everything is fine.What could be the reason behind this issue? My understanding is that ExVcr mocks the functions in the Finch module. Are these mocks global? If that's the case then it's no surprise that the other async Bypass-based tests occasionally fail, because they need to hit the real Finch implementation to talk to the Bypass server.
Am I right in this assumption? If so, is there a way to restrict the mocks to the current test only, so that other tests running in parallel will use the real implementation?
this is the preamble of my test file:
I have no global config for ExVCR.
For Tesla I have this in my config:
And I start the Finch process with this child spec in my
application.ex
:(All very standard as you can see)