๐ Parent Note
๐ค Situation
Let's suppose that you have a panel and test it's changed from open to closed.
๐ Bad code
expect(find('div.target > div.message', visible: false).visible?).to eq true
find('div.target').click # the panel will be closed.
expect(find('div.target > div.message', visible: false).visible?).to eq false
# Error because Capybara is too fast ๐ญ
# ---
# Failure/Error
# expected: false
# got: true
๐Good code
Let's use Capybara::RSpecMatchers#have_selector.
Then, Capybara waits the animation until the test is green.
expect(find('div.target').to have_selector('div.message')
find('div.target').click
expect(find('div.target').not_to have_selector('div.message')
Top comments (0)