Minitest reporter that automatically creates a screenshot on error or failure during capybara webtests. It works both in visible browser tests, as well as with headless tests.
Add this line to your application's Gemfile:
group :test do
gem 'minitest-reporters'
gem 'minitest-screenshot-reporter'
gem 'capybara' # dsl for browser tests
gem 'selenium-webdriver' # use real browser for webtests
gem 'poltergeist' # headless tests with phantom.js
end
And then execute:
$ bundle
Use as any other minitest reporter with `Minitest::Reporters.use!
Example: Add following to your test_helper.rb:
require 'minitest/reporters'
require 'minitest/reporters/screenshot_reporter'
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new,
Minitest::Reporters::ScreenshotReporter.new]
Run your tests, and if there are errors or failures in your integration tests, check the directory test/screenshots.
You can also include the Minitest::Reporters::Screenshot
module to your integration test class. Than you can use the method screenshot(name)
to explicitly create additional screenshots in test/screenshots in your integration tests.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, run bundle exec rake release_patch
, bundle exec rake release_minor
, oder bundle exec rake release_major
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to https://rubygems.org.
Bug reports and pull requests are welcome on github at https://github.com/igorj/minitest-screenshot-reporter.
The gem is available as open source under the terms of the MIT License.