Skip to content

mwhitworth/percy_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Percy client for Elixir

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
end

Prerequisites

Wallaby

Percy 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.

Percy

npm install -g @percy/cli

for the percy command line tool that provides the infrastructure for screenshots. (https://github.com/percy/cli)

Installation

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}
  ]
end

Test functions

snapshot(session, name, opts \ [])

For 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.

percy_enabled?

Returns true if the local Percy server is running, false otherwise.

About

Percy client for Elixir (using Wallaby)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages