Using the ChannelCase I can assert that certain events are happening, and that I receive certain replies from the server. However, I haven’t found a way to assert changes to the socket.assigns. I alter the state to keep track of what has happens during a chat, and I want to test that whatever I expect to happen actually happens. How would I go about doing that?
Hey @Pistrie in general I would consider tests that assert on the actual channel state a bit “brittle” and favor tests that assert on observable behavior.
However, if you do want to assert on internal state, you can leverage the bit where a channel is simply a genserver at the end of the day and do:
state = :sys.get_state(pid)
Now notably the state you’re going to get back is the Phoenix process state, so you’ll need to dig into it a bit to get your assigns.