No release in over 3 years
Low commit activity in last 3 years
Allows you to execute a block or raise a warning if you use a finder that reaches capybara's timeout.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

~> 2.0
 Project Readme

Capybara::TimeoutReporter

Gem Version

Speed up your Capybara tests by detecting and fixing finders that reach sync timeout.

Description

Capybara gem is very popular in ruby community for browser-based UI test automation of web apps. Capybara has quite powerful synchronization mechanism built in, which allows you to write tests that wait automatically until AJAX requests are completed, elements become visible, etc. However, very often engineers do not keep this Capybara feature in mind and write code like this:

# this line will be executing for 'Capybara.default_wait_time' seconds
refute page.has_css?('.some-non-existent-class')

Or like this:

if page.has_css?('.some_class')
  # no timeout occured in this case
else
  # "has_css?(...)" will be executing for 'Capybara.default_wait_time' seconds in this case
end

Wrong usage of Capybara makes your tests slow!

capybara-timeout_reporter gem helps you to detect all places where your finders are reaching a timeout and report them.

Installation

gem install capybara-timeout_reporter

or if you're using bundler, add this line to Gemfile:

gem 'capybara-timeout_reporter

Usage

Just load it after capybara gem:

require 'capybara'
# load timeout_reporter after capybara
require 'capybara/timeout_reporter'

Basic usage

Default beviour, in case of Capybara sync timeout the following warning will be printed into STDOUT:

[WARNING] Capybara find timed out after <number_of_seconds> seconds in </path/to/file.rb>:<line_number> 

Advanced usage

# somewhere in your test_helper.rb, spec_helper.rb, evn.rb, etc.
Capybara::TimeoutReporter.on_timeout do |timeout_value, src_line|
  # do whatever you want, for example:
  # - raise an exception, if you want to make this strict 
  # - add an entry to test report, if you have one
  # - write to a log file
  # - collect all timeouts and then report a total time wasted
end

Contributing

  1. Fork it https://github.com/vgrigoruk/capybara-timeout_reporter/fork
  2. Create your feature branch (git checkout -b new-feature)
  3. Commit your changes (git commit -am 'Added feature')
  4. Push to the branch (git push origin new-feature)
  5. Create a new Pull Request