Inspired by Kat Tornwall’s talk about integration tests with Elixir and Phoenix I did some clean up in my integration tests of my current Elixir project. Look how much more readable they are now.
Page modules for navigation
Instead of using all this navigation stuff like
find_element(:id, "get-state-button") |> click()
I can simply write
assert Regex.match?(...) inlined will end up in assert messages like expected true but was false which is really annoying and won’t tell me the real error. So, I wrote a macro, thus I can use
assert_regex(expected,text) which will tell me exactely what was searched for but not found in which text.
The test above is so much more readable now, isn’t it.
And the effort wasn’t a big deal. Here is what I had to extract into helpers.