← Graph

How do you test rendered Phlex components?

question 2 connections

Audience question about automated testing of Phlex-rendered views — e.g. feature specs in RSpec — without having to walk the full DOM to find an element. Answers: right now Ruby UI compares the raw rendered string. The Phlex documentation includes a guide for setting up a test helper and piping the HTML into Nokogiri, Capybara, or any query library to use CSS selectors. Stephen Margheim has floated the idea of Phlex compiling to a queryable data structure (e.g. an AST) instead of HTML in the test environment. Joel Drapper sees an even faster approach: you declare the assertions you want to make about a component and Phlex 'pseudo-renders' it just enough to tell you whether those assertions would have been met — skipping the actual HTML production and yielding much faster test runs.

answer_summary
Today: render to string and query with Nokogiri/Capybara (a helper is documented). Future: compile to a queryable AST in test mode, or pseudo-render against declared assertions for faster tests.
question How do you test rendered Phlex components?
about
Phlex tool
Testing story for Phlex.
question How do you test rendered Phlex components?
asked_at
Audience Q&A on testing Phlex-rendered UI.

Provenance

Read by
4 extractions