How to use ^ operator in testing assert function

my_topic = "my_topic" <>

    assert_receive %Phoenix.Socket.Broadcast{
        topic: ^my_topic,
        event: "update",
        payload: %{id: ^, status: "ongoing"}

I got an error

invalid argument for unary operator ^, expected an existing variable, got: ^

How can I insert value to assert function in test?

1 Like

You can only use ^ with variables. First bind the expression to a variable and then match it:

var =
assert ^var = value