how to embed a screenshot in html report for every scene that passes in rspec

628 Views Asked by At

When I do the automated tests the capybara generates an html with the report of the tests that passed or nao.com the cucumber of the to embed the photos of the tests in the html report

how to embed a screenshot in html for every scene that passes in rspec??

has a method in the cucumber that embed the screenshot in html embed(screenshot, 'image/png', 'Click here')

but in rspec i not found.

1

There are 1 best solutions below

0
Phil On

In your spec_helper you can do:

Rspec.configure do |config|
  config.after(:each) do
    page.save_screenshot('image_%s.png' % rand(1000).to_s)
  end
end

If your formatter is outputting html it should just embed it into the html after each passing scenario.