TestServer - No fuzz mocking of third-party services

Tests are run synchronously, and the issue is reproducible running a single test case in isolation as well.

I could be doing something wrong in the “testing Phoenix.Presence” side of things. I’ve read the few threads on the topic I could find in this forum, including Handling Phoenix Presence during testing - #3 by luizpvasc. I originally worked on this already some time ago, memory is a bit vague, but I think it is related to how Presence “fetchers” work asynchronously, process linking and termination.

So I considered posting on that topic, but then thought maybe TestServer could just be less strict about the number of calls. Reading the implementation a bit more last night, I believe that’s not possible, though.

TestServer always sets up an ExUnit on_exit callback that checks routes: if anything is left unvisited it errors out.

And when an unexpected request comes, it produces the warning:


I think either I need to understand how to test Phoenix.Presence in a more deterministic way, spin up a dumb server that doesn’t assert on the number of mocked calls, or mock at the HTTP client level.