Supress the output of flush()

Hi,

I am writing some unittest for phoenix channel.

For the sake of convenience in debugging, I want to flush message mailbox the unittest process receive during the unittest, then push new socket message and assert new reply.

But I don’t want to mess up the output of my terminal when using flush(), how can I supress the output of flush() or Should I use other method to clean the mailbox?

Thanks.

1 Like

Hi, @tl-jasonwu

Could you please share some example of the code and what you are trying to achieve?

1 Like

Hey @tl-jasonwu simply write your own flush helper:

def clear_mailbox() do
  receive do
    _msg -> clear_mailbox()
  after
    0 -> :done
  end
end
5 Likes

Hi @benwilson512 thanks your answer.
It solved my problem.