Difftastic - a wrapper for structural diffing tool

I released the first version some time ago, but I think that with today’s 0.2.0 it became potentially interesting. The library wraps Difftastic CLI in Elixir code, so it can be invoked and used throughout your app.

Link: GitHub - katafrakt/difftastic-elixir: diffing on steroids, now in Elixir

Version 0.2 brought a simple tooling for snapshot tests. Here’s how it looks like:

defmodule Snap.AccountsTest do
  use Snap.DataCase
  use Difftastic.SnapshotTest, dir: "test/snapshots/email"

  test "snapshot" do
    user = user_fixture()
    {:ok, email} = Accounts.deliver_user_update_email_instructions(user, "current@example.com", fn _ -> "test" end)
    assert_snapshot_match("user_update.html", email.html_body)
  end
end

This creates a snapshot on the first run and stores it in test/snapshots/email. In that manner it’s mostly inspired by Snapshy. However when on a subsequent run the email content is changed and does not match the snapshot, the error message is much more to-the-point:

The requirement is that the user to have Difftastic installed on their systems.

6 Likes