Skip to content

Suggestion: add a some test utilities. #24

@Gladear

Description

@Gladear

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 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions