https://github.com/mwhitworth/percy_client
Percy client for Elixir (using Wallaby)
https://github.com/mwhitworth/percy_client
elixir percy-io wallaby
Last synced: 2 days ago
JSON representation
Percy client for Elixir (using Wallaby)
- Host: GitHub
- URL: https://github.com/mwhitworth/percy_client
- Owner: mwhitworth
- Created: 2024-01-17T14:35:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-01T14:00:53.000Z (over 1 year ago)
- Last Synced: 2025-09-19T01:49:27.591Z (24 days ago)
- Topics: elixir, percy-io, wallaby
- Language: Elixir
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Percy client for Elixir
An Elixir client for the visual testing and regression service [Percy](https://percy.io), following the instructions
in the ["Build your own SDK" section](https://www.browserstack.com/docs/percy/integrate/build-your-sdk) of the documentation.The full documentation for this library can found on [HexDocs](https://hexdocs.pm/).
```elixir
defmodule MyApp.PercyTest do
use ExUnit.Case, async: true
use Wallaby.Featurefeature "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](https://github.com/elixir-wallaby/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](https://github.com/elixir-wallaby/wallaby?tab=readme-ov-file#setup)
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`:
```elixir
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](https://www.browserstack.com/docs/percy/take-percy-snapshots/overview#all-configuration-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.