This provides a way to receive emails from other processes without
resorting to shared mode and synchronous tests.
For background, this builds on some work that I did to allow Wallaby
tests to play nicely with Mox, while still allowing the tests to be
async. I wrote about it here:
This commit basically implements a kind of Mox.allow/3 function for
Bamboo.TestAdapter.
Note that I’ve changed the order of the arguments for this
Bamboo.TestAdapter.forward/2 function. For Mox.allow/3, the owner_pid
comes first:
Mox.allow(MyMock, owner_pid, child_pid)
But for Bamboo.TestAdapter.forward/2, the child_pid comes first:
Bamboo.TestAdapter.forward(child_pid, owner_pid)
My reasoning is that in the first example we’re allowing the child_pid
to access mocks defined by the owner pid. But in the second example,
we’re forwarding emails FROM the child_pid TO the owner_pid. So this
order of arguments seemed to make sense to me, but may be slightly
confusing.
Thanks for opening this PR @jonleighton! I really like the idea of what you're doing here. I'll try to find some time later this week to give it a good review.
This provides a way to receive emails from other processes without resorting to shared mode and synchronous tests.
For background, this builds on some work that I did to allow Wallaby tests to play nicely with Mox, while still allowing the tests to be async. I wrote about it here:
https://jonleighton.name/2021/asynchronous-browser-tests-with-phoenix/
And then contributed some docs to Wallaby about the setup here:
https://github.com/elixir-wallaby/wallaby/pull/592
This commit basically implements a kind of Mox.allow/3 function for Bamboo.TestAdapter.
Note that I’ve changed the order of the arguments for this Bamboo.TestAdapter.forward/2 function. For Mox.allow/3, the owner_pid comes first:
But for Bamboo.TestAdapter.forward/2, the child_pid comes first:
My reasoning is that in the first example we’re allowing the child_pid to access mocks defined by the owner pid. But in the second example, we’re forwarding emails FROM the child_pid TO the owner_pid. So this order of arguments seemed to make sense to me, but may be slightly confusing.