Hello!
I write LiveView tests using GitHub - iamvery/skipper style helpers (awesome library btw, thank you @iamvery). I added assert_title/2
to easily ensure I’m on the right page and that the page title is correct.
test "example", %{conn: conn} do
conn
|> visit("/")
|> assert_title("Home")
end
However, mix format
enforces the live title to be formatted like so:
<.live_title suffix=" · Phoenix Framework">
<%= assigns[:page_title] %>
</.live_title>
This adds extra spaces, causing the outputted HTML to look like this:
<title data-suffix=\" · Phoenix Framework\">\nHome\n · Phoenix Framework</title>
Having the <.live_title>
on a single line works as expected:
<title data-suffix=\" · Phoenix Framework\">Home · Phoenix Framework</title>
Asserting the title does work, but it’s a bit funky:
assert html =~ ~s(<title data-suffix=" · Phoenix Framework">\n#{title}\n · Phoenix Framework</title>)
We have mix format --check-formatted
in our CI, so not formatting the file isn’t an option either.
Has anyone dealt with this kind of issue or do you have a better way of dealing with this?
Or is there a way to ignore that part from being formatted?