Using Capybara, is there a way to expect there to be no alert on the page? I'm thinking something along the lines of:
click_link('some link')
expect(page).to have_no_alert
Or something along those lines.
Using Capybara, is there a way to expect there to be no alert on the page? I'm thinking something along the lines of:
click_link('some link')
expect(page).to have_no_alert
Or something along those lines.
No, Capybara does not provide anything like that, and all alert handling methods take the block that would open the alert so writing your own matcher to do it isn't straightforward.
You could do something along the lines of
expect do
accept_alert do # may want to pass a `wait` option to `accept_alert` to shorten how long it will check for an alert to exist
click_link('some link')
end
end.to raise_error(Capybara::ModalNotFound)