Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows custom format width #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wingyplus
Copy link

Hi,

Thank you for making this library. It help me and my team save testing time a lot. ❤️

I create this patch to custom format line width. The previous one is fixed to only 80.

Why is it matter

In my daily work, I have csv table like data structure (list of list) to test in unit test, columns quite a lot, and current snapshot format width make it hard to read (but it's better than asserting in unit test!).

Comparing width at 80 vs 500:

80

Screenshot 2566-09-15 at 10 26 19

500

Screenshot 2566-09-15 at 10 09 42

Make format width argument in `Inspect.Algreba.format` customizable
though `Config`.

Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com>
@@ -184,8 +184,7 @@ defmodule Snapshy do
value
|> Inspect.Algebra.to_doc(inspect_options())
|> Inspect.Algebra.group()
|> Inspect.Algebra.format(80)
|> Enum.join()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also remove Enum.join since File.write can accept iodata. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant