ExUnit: Assertion with "in" failed

{:username, {""should be at most %{count} ...", ...} is how the errors are represented in the your_changeset.errors keyword list.

errors_on/2, which is a Phoenix test helper, transforms the errors into another keyword list by using Ecto.Changeset.traverse_errors/2 - what you get back is e.g.: [username: "should be at most 20 character(s)"].

Thus, in your test you need to either do:

  1. assert {:username, {"should be at most %{count} ...", ...}} in changeset.errors
  2. assert {:username, "should be at most 20 character(s)"} in errors_on(...)
1 Like