Polychrest
Rack middleware to trap javascript errors and inject them in the DOM so capybara drivers without javascript error reporting can find them.
Installation
Add this line to your application's Gemfile:
gem 'polychrest'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install polychrest
Usage
To start tracking errors, set the TRACK_JS_ERRORS
environment variable:
$ export TRACK_JS_ERRORS; cucumber
or set it in a hook:
Around('@javascript') do |scenario, block|
ENV['TRACK_JS_ERRORS'] = 'true'
block.call
ENV.delete('TRACK_JS_ERRORS')
end
and then inspect the DOM for errors:
page.should_not have_css('.js_errors')
You can look for specific errors as well:
page.should have_css('.js_errors', text: /createTextNode/i)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request