Skip to content

Instantly share code, notes, and snippets.

@fotinakis
Created September 23, 2015 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fotinakis/a5a6515b5099335ac9a6 to your computer and use it in GitHub Desktop.
Save fotinakis/a5a6515b5099335ac9a6 to your computer and use it in GitHub Desktop.
Percy wait_for_animation for JavaScript animations
RSpec.feature :homepage, js: true do
def finished_all_animations?
page.evaluate_script('$(":animated").length') == 0
end
def wait_for_animation
Timeout.timeout(Capybara.default_wait_time) do
sleep 0.1 until finished_all_animations?
end
end
scenario 'user clicks toggle and section appears' do
visit '/'
find('#toggle-post-dialog').click
wait_for_animation
expect(page).to have_content('Share')
Percy::Capybara.snapshot(page, name: 'homepage with input')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment