elixir
elixir copied to clipboard
ExUnit only formats the common parts between left and right side of assertion
Elixir and Erlang/OTP versions
Elixir 1.17.0-rc.0 (a2600ea) (compiled with Erlang/OTP 27)
Operating system
Linux
Current behavior
With such minimal test:
@date DateTime.utc_now() |> Map.from_struct()
test "greets the world" do
assert [@date] == [@date, @date]
end
The result has only formatted the common parts of both sides of the comparison.
The difference is unformatted, but this is the one that I'm as an user am most interested in. It looks worse when the data structure has more keys than on the screenshot.
Expected behavior
The differences between both sides are formatted.
Better example - when something does not match partially it is formatted:
I created a pr #13631 there are few possible ways how to solve this.
I believe the correct way to solve this is to attach some metadata to nodes and pass that metadata to the code formatter. Given the formatter already understands coloring, perhaps it won't be such a major issue.
I started to look at it again and this came out, I think it's simpler than adding additional metadata.