System test: asserting Turbo Stream responses

14933
0

I don’t test Hotwire behavior by guessing; I add system tests that exercise the UI. With Capybara, I click a button that triggers a Turbo Stream response and assert that the DOM changes without a full page reload. The exact assertion depends on the feature: a row disappears, a counter increments, a toast appears. In Rails system tests, you don’t need to parse turbo stream tags directly; you validate the user-visible result. I also like to use assert_text and assert_selector with stable ids (dom_id). This catches regressions when a template stops responding with turbo streams or when a status code changes. It’s the quickest way to keep Hotwire UX reliable.