AssertMatch

Elixir CI

Leverages pattern matching & pipeline in Elixir tests!

Motivation

In short, we wanted this:

test "/some/api should work", context do
  conn
  |> post("/some/api")
  |> json_response(200)
  |> assert_match(%{
    "success" => true,
    "id" => ^context.some_fixture.id,
    "bytesize" => ^byte_size(context.some_fixture.contents)
  })
end

Introductory talk

<img src="slide.png" alt="Further leveraging pattern matches in Elixir unit tests!" width="320"/>

Installation

def deps do
  [
    # If available in Hex
    {:assert_match, "~> 1.0", only: [:test]}
    # If not, or, if you need bleeding edge
    {:assert_match, github: "siiibo/assert_match", ref: "main", only: [:test]}
  ]
end