At times, I want to test my generated HTML pretty extensively.
LazyHTML already makes it possible, but having some test utility functions would be welcome - either in a dedicated module, or directly in the main LazyHTML module, that I do not know.
The two examples that come to my mind right now would be
- a
matches?(doc, selector) function, that basically corresponds to doc |> LazyHTML.filter(selector) |> Enum.empty?() |> Kernel.not()
- a
exists?(doc, selector) function, that simplifies doc |> LazyHTML.query(selector) |> Enum.empty?() |> Kernel.not()
--
Now that I see it this way, maybe a LazyHTML.exists?(doc) that just verifies that a query or filter returned an element would be nice 😄
At times, I want to test my generated HTML pretty extensively.
LazyHTML already makes it possible, but having some test utility functions would be welcome - either in a dedicated module, or directly in the main
LazyHTMLmodule, that I do not know.The two examples that come to my mind right now would be
matches?(doc, selector)function, that basically corresponds todoc |> LazyHTML.filter(selector) |> Enum.empty?() |> Kernel.not()exists?(doc, selector)function, that simplifiesdoc |> LazyHTML.query(selector) |> Enum.empty?() |> Kernel.not()--
Now that I see it this way, maybe a
LazyHTML.exists?(doc)that just verifies that a query or filter returned an element would be nice 😄