An Elixir client for the visual testing and regression service Percy, following the instructions in the "Build your own SDK" section of the documentation.
The full documentation for this library can found on HexDocs.
defmodule MyApp.PercyTest do
use ExUnit.Case, async: true
use Wallaby.Feature
feature "home page functionality" do
session
|> visit("/home")
|> PercyClient.snapshot("initial home page", widths: [360, 1280])
end
endPercy requires a live browser session to inject Javascript and take a snapshot of the DOM. Wallaby is a library that creates a browser session (using ChromeDriver or Selenium) to interact with.
Ensure that the steps described in the project README's "Setup" section are completed.
npm install -g @percy/cli
for the percy command line tool that provides the infrastructure for screenshots. (https://github.com/percy/cli)
The package can be installed by adding percy_client to your list of dependencies in mix.exs:
def deps do
[
{:percy_client, "~> 0.1.0", only: :test}
]
endFor a given Wallaby session session, takes a screenshot of name name by checking to see if the local percy instance is running,
injecting the DOM with the Percy snapshot script and uploading it to the local running percy instance. You can pass the
Percy options as opts, though
the snapshot options with a dash listed should be passed as atoms with an underscore separator, to follow Elixir conventions
(e.g. min-height: 600 in JSON should be min_height: 600 in the keyword list)
Returns :ok if the screenshot was taken without issue.
Returns true if the local Percy server is running, false otherwise.