We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Resolving Flaky Tests with Faker in Elixir
213
clicks
Source: johnelmlabs.com
John Elm Labs outlined a common issue encountered with flaky Elixir tests, specifically when using Faker to generate data that may include HTML-encoded characters such as apostrophes. This problem arises when using Faker with Floki (an HTML parser utilized by LiveView Test) because Floki HTML-encodes certain characters by default, which can result in failed test assertions. To address this, Curran recommends a configuration setting in the test environment to prevent Floki from HTML encoding the raw HTML. This fix involves adding the line 'config :floki, :encode_raw_html, false' to 'config/test.exs'. Curran also explained that this solution does not apply to controller tests using html_response/2, suggesting instead that developers implement a helper function to explicitly HTML-encode values within their assertions.
Related posts
© HashMerge 2024