joshua.aug
Is there a way to make output not print charlists in tests?
Let’s say I make a assert in a test. If there is a failure the logs will show like this:
left: %{
1 => [
%{
count: 1,
group_rating: 21,
members: ~c"d",
ratings: [21]
},
%{count: 1, members: ~c"e", group_rating: 2, ratings: [2]}
],
Here ~c"e" should print an array of numbers. Any way to change this behaviour? Is there a config file I can place somewhere in my project?
Most Liked
voughtdq
Very interesting question. It doesn’t seem like that’s currently possible without creating a custom formatter. Being able to provide Inspect.Opts to the default ExUnit formatter would be a big win.
sodapopcan
I agree. I was looking into this question last night and was surprised I couldn’t find anything. I was also surprised I’ve never run into this myself!
@joshua.aug for now you can use dbg(failing_data, charlists: :as_lists) just so you can see better what’s going on. It’s not ideal but it’s the best I can come up with for now without suggesting you write your own formatter ![]()
D4no0
This is a very interesting idea. I’ve had some projects with binary protocol parsers that would benefit highly from a custom formatter, as it is incomprehensible when it starts to spew charlists for thousands of lines
.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










