How to test for presence of image asset

The code in response_content_type gives the error message you’re encountering if this function returns false:

https://github.com/phoenixframework/phoenix/blob/cdf0eb83d51584e046770d95c6aaf53fd4c4ac95/lib/phoenix/test/conn_test.ex#L326-L335

Here {part, subpart} will be {"image", "png"}, so you’ll need to pass a format that passes one of the three conditions:

  • matches the result of running MIME.extensions("image/png") - ["png"] on my system
  • is equal to subpart
  • is at the end of the subpart preceded by a +

The third condition doesn’t seem relevant, and the other two are the same. You should pass :png to response_content_type. You may not need the =~ part unless you’re doing something unusual:

assert response_content_type(conn, :png)