Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

mcrumm/elogram

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELogram

Capture screenshots with the Phoenix.LiveViewTest Element API.

This package is EXPERIMENTAL and should not be used by anyone.

Installation

The package can be installed by adding elogram to your list of dependencies in mix.exs:

def deps do
  [
    {:elogram,
       only: :test, git: "https://github.com/mcrumm/elogram.git"}
  ]
end

Capturing Screenshots

Start the screenshots server in test/test_helper.exs:

+ Elogram.start([])
ExUnit.start()

Then capture a screenshot from your LiveView:

defmodule MyAppWeb.PageLiveTest do
  use MyAppWeb.ConnCase

  import Phoenix.LiveViewTest
  import Elogram.CaptureScreenshot

  test "a thousand words", %{conn: conn} end
    {:ok, view, _} = live(conn, "/")

    assert view
           |> capture_screenshot(name: "welcome.png")
           |> render() =~ "Welcome to Phoenix!"
  end
end

Test Setup

Headless Chrome

Start a headless browser before running your tests:

Github Actions

steps:
    - name: Start Google Chrome
      run: google-chrome --headless --disable-gpu --remote-debugging-port=9222 &

MacOS

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --remote-debugging-port=9222

Save Path

By default screenshots will be saved to tmp/screenshots, so you may wish to update your .gitignore file to include the tmp directory:

# Temporary files for e.g. tests
/tmp

About

A mechanism to capture screenshots from Phoenix LiveView tests without a camera.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.