← Graph

How do you test ViewComponents and Hotwire flows?

question 2 connections

Attendee notes that in React, component tests often rely on artificial supplied data that drifts from the real backend, and asks whether being in Rails makes it easier to test ViewComponents with real data. Answer: write a spec file with factory-built objects and regular RSpec assertions on what should/shouldn't be rendered, use snapshot testing to detect changes, and use Rails system tests for end-to-end flows that involve Turbo Stream or Turbo Frame requests. Asked which is better to test, Yaroslav says personally he prefers writing Ruby assertions for ViewComponents — easier for him as a Ruby developer.

answer_summary
Use RSpec assertions on factory-built objects, snapshot tests for ViewComponents, and Rails system tests for Turbo Stream/Frame flows; easier for a Ruby developer than React.
question How do you test ViewComponents and Hotwire flows?
about
Asks how ViewComponent testing compares to React component testing.
question How do you test ViewComponents and Hotwire flows?
asked_at
Asked in Q&A at the end of the talk.

Provenance

Read by
3 extractions