elixir icon indicating copy to clipboard operation
elixir copied to clipboard

ExUnit only formats the common parts between left and right side of assertion

Open dkuku opened this issue 1 year ago • 2 comments

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. image

Expected behavior

The differences between both sides are formatted.

dkuku avatar May 31 '24 15:05 dkuku

Better example - when something does not match partially it is formatted: image

dkuku avatar May 31 '24 16:05 dkuku

I created a pr #13631 there are few possible ways how to solve this.

dkuku avatar Jun 04 '24 14:06 dkuku

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.

josevalim avatar Oct 30 '24 08:10 josevalim

I started to look at it again and this came out, I think it's simpler than adding additional metadata.

dkuku avatar Nov 03 '24 01:11 dkuku