Ever wanted to run your integration/end-to-end test suite at a lower speed so that you better could observe what's happening and perhaps make a recording of it?
Here's a a technique I've been using when writing tests with Capybara Selenium WebDriver.
Put this in test/test_helper.rb
or maybe something like spec/support/capybara.rb
.
# For running Selenium at a lower speed
# Very useful when recording test runs
# https://stackoverflow.com/a/46840590/2037928
if ENV["SLOW"].present?
require "selenium-webdriver"
module ::Selenium::WebDriver::Remote
class Bridge
alias old_execute execute
def execute(*args)
sleep(0.1)
old_execute(*args)
end
end
end
end
Then set the SLOW=1
environment variable whenever you want to run your tests in slow motion. For example:
SLOW=1 rails test test/system
SLOW=1 rspec spec/features
Then if you want to make a recording to GIF I'd recommend LICEcap https://www.cockos.com/licecap/ which I've been using for years now.
Thanks to Ken Mayer for this solution on StackOverflow