Skip to content

Floki encodes special characters in LiveView tests unless encode_raw_html is off

February 15, 2024

Floki, the HTML parser LiveViewTest uses, encodes certain characters by default. Faker, a library for fake test data, sometimes generates data with special characters, so the two can conflict in test assertions.

To stop Floki from encoding HTML special chars, just add this:

# config/test.exs
config :floki, :encode_raw_html, false

—

Back to TIL

Next: An SVG favicon can be a single emoji in a text element

Phil-Bastian Berndt

Phil-Bastian Berndt
Tech Lead at Naymspace