vt-elixir / ja_serializer

JSONAPI.org Serialization in Elixir.
Other
640 stars 148 forks source link

Missing documentation for testing Phoenix controller responses #331

Closed leandro closed 4 years ago

leandro commented 4 years ago

Hi. I'm currently missing some documentation on the recommended way of testing controller actions, where I actually need to check the JSON response in a more automated way (without having to assert the JSON response against a manually typed/paste arbitrary structure).

I'm asking for some light on this because it's burdensome when it comes about checking the JSON response of index actions (for instance), where it normally outputs a collection in JSON-API format. And if using PhoenixView module, it's not clear to me what's a good way to test the response. Is there any?

beerlington commented 4 years ago

The short answer is no, there isn't a preferred or recommended way of doing this. I've worked on different projects that have all done it different ways - each having pros and cons. I've seen some attempts at validating JSON API responses in different elixir projects, but never come across something that I've really loved. I agree it's burdensome and would love to find a solution to this.

leandro commented 4 years ago

@beerlington I see. Thanks nonetheless for your candid response. I guess I'll simple assert against the first item of the collection and maybe the size of it too. That will suffice for now. I believe you now close this issue.