dashbitco / dashbitco/lazy_html

Suggestion: add a some test utilities.

Open
#24 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
105
Forks
16
Avg merge
7d 23h
Merged PRs (30d)
1

Description

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 😄

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing LazyHTML.filter/2 and LazyHTML.query/2, which the issue identifies as the operations the utilities would simplify. Resolve whether the project should provide matches?, exists?, or another API, then add the selected test helpers and tests showing that they correctly report matching or queried elements.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.