Skip to content

iamvery/skipper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skipper

Build Status Hex.pm

LiveView tests tend to leak details that distract from the system behavior you're testing. Skip the noise and let the Skipper patch the leaks so you can sail on in your well-tested craft.

Installation

If available in Hex, the package can be installed by adding skipper to your list of dependencies in mix.exs:

def deps do
  [
    {:skipper, "~> 0.3.0", only: :test}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/skipper.

Phoenix LiveView Test Helpers

I've put together a set of test helper functions for testing Phoenix LiveView. For more details on this pattern, see the blog post.

As a quick example, the helpers let you go from:

import Phoenix.LiveViewTest

test "live view", %{conn: conn} do
  {:ok, live, html} = live(conn, "/")
  assert html =~ "New"
  assert live |> element("a.new") |> render_click() =~ "Enter new"
  assert_patch(live, "/new")
  {:ok, _, html} = live |> form(".form", @attrs) |> render_submit() |> follow_redirect(conn)
  assert html =~ "success"
end

To:

use Skipper.LiveViewTest

test "live view", %{conn: conn} do
  start(conn, "/")
  |> assert_visible("New")
  |> click("a.new")
  |> assert_visible("Enter new")
  |> submit_form(".form", @attrs)
  |> assert_visible(".alert", "success")
end

Copyright and License

Copyright (c) 2022, Jay Hayes.

Source code is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published