Jason.Encoder Error when running mix test in umbrella root

I have a controller that returns a json and my controller_test fails everytime I run mix test in the root of my umbrella project: ** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for schema

It works when I mix test in app_web folder though. I already put @derive {Jason.Encoder, only: [....]} in my schema. My tests in the context also works. Is there any config I missed? Also I don’t use view. I just return straight

|> put_status(200)
|> put_resp_header("content-type", "application/json")
|> json(%{
    data: result

in the controller.

1 Like

run into the same issue,
for me, it was because I used:

@derive Jason.Encoder

change to:

@derive [Jason.Encoder]

now everything is fine with tests in the umbrella root

1 Like