<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="240883" data-post-id="240883">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="ColmB" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/ColmB/120/25562_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  ColmB
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Sorry to drag this thread back up, but it is now the <span class="hashtag-raw">#1</span> hit for the UnexpectedCallError in the OP. Just to note that beyond the more esoteric situations discussed in the thread so far, you can also see this error via a simple race condition. This situation is discussed in the doco under Blocking on Expectations at <a href="https://hexdocs.pm/mox/Mox.html#module-multiple-behaviours" class="inline-onebox" rel="noopener nofollow ugc">Mox — Mox v1.2.0</a>. It also comes up a few times in the closed Mox issues. Basically if the test finishes before any spawned processes then Mox will tear down the expectations before the tested behaviour uses it. Can be very confusing as you may partial mock hits where it is set to expect multiple hits. One way around it is to force the test to wait by messaging from within the mock. From that doco:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">test "calling a mock from a different process" do
  parent = self()
  ref = make_ref()

  expect(MyApp.MockWeatherAPI, :temp, fn _loc -&gt;
    send(parent, {ref, :temp})
    {:ok, 30}
  end)

  spawn(fn -&gt; MyApp.HumanizedWeather.temp({50.06, 19.94}) end)

  assert_receive {^ref, :temp}

  verify!()
end
</code></pre>
<p>Hope that helps someone in a similar situation!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="240883" data-batch-url="/posts/batch_likers">
                        6
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/mox-mocks-not-working-for-other-processes/22011/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-240883" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="240883"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-most-liked cat-most-liked" title="One of the top 3 liked posts in this thread!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>