These past couple of weeks we've been improving our existing feature spec suite to prepare it for switching over to --headless=new
chrome option.
Several of the existing specs had to be updated with proper awaiting, for example
click_button "Update"
expect(record.reload.field).to eq("new value")
oftentimes failed because the button click hadn't been fully processed yet, so
click_button "Update"
expect(page).to have_flash_message("Update successful")
expect(record.reload.field).to eq("new value")
Another source of deeper fragility was the behavior of .set
and fill_in
- sometimes, especially if an input already had a value, the new value would either be appended or not inputted at all.
We significanly reduced the incidence of these fails by specifying a clear option like this:
config.before(:each, :js) do
Capybara.default_set_options = { clear: :backspace }
end
Top comments (0)