Writing reliable system tests with Hotwired Turbo is tricky because Turbo's aria-busy attribute briefly disappears during form submit-redirect cycles, causing flaky tests. This post walks through building a wait_for_turbo Capybara helper that checks for multiple DOM states: aria-busy on html/form/turbo-frame elements, a custom data-turbo-not-loaded attribute (set server-side, removed after Turbo loads), a data-turbo-loading attribute to bridge the aria-busy gap during redirects, and data-turbo-preview. The helper is then integrated directly into Capybara's click method via module prepend so tests don't need manual wait calls scattered throughout.

4m read timeFrom island94.org
Post cover image
Table of contents
Enumerating states Turbo can be inDoing the simplest thing about itI hate it

Sort: