--breakpoint flag changes the behaviour of mix test using bypass

Is it possible that when ran without breakpoints the test finishes before the process makes the call. While with breakpoints, by the time you press c, Manage.login/2 makes its way to send the message?

I’d try to synchronize the test and Bypass with something like:

test "logs in user correctly", %{bypass: bypass, credentials: credentials} do
  test_pid = self()

  Bypass.expect_once(bypass, fn conn ->
    IO.inspect(conn.request_path, label: "REQ PATH")
    IO.inspect(conn.method, label: "METHOD")
  
    send(test_pid, :logging_in)
    
    Plug.Conn.resp(conn, 429, ~s<{"errors": [{"code": 88, "message": "Rate limit exceeded"}]}>)
  end)
  
  _manager_pid = start_link_supervised!(ManagerSupervisor)
  Manager.login(credentials, false)

  # this ensures that the test will not exit until the message is received
  # (or until the default `assert_receive` timeout 100ms)
  assert_receive :logging_in
end
2 Likes