Skip to content

Ruby Test Framework Integration

RSpec with Capybara

require 'vizzly'
RSpec.describe 'Homepage', type: :feature do
it 'renders correctly' do
visit '/'
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot('homepage', image_data,
properties: {
browser: Capybara.current_driver.to_s
}
)
end
end

Helper module

module VizzlyHelpers
def capture_screenshot(name, **options)
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot(name, image_data, **options)
end
end

Forward the full options hash in helpers. That keeps threshold, min_cluster_size, full_page, build_id, and request_timeout available instead of accidentally dropping everything except properties.

Minitest

image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot('dashboard', image_data)

Cucumber

When('I capture a screenshot named {string}') do |name|
image_data = page.driver.browser.screenshot_as(:png)
Vizzly.screenshot(name, image_data)
end

Good habits

  • Use stable screenshot names.
  • Add properties for variants like device, theme, or state.
  • Run through vizzly run in CI when you want cloud results.

Next steps