NLdoc.Test.Snapshot (NLdoc.Test v3.0.2)

View Source

This module provides snapshot testing functionality for ExUnit tests.

Summary

Types

destination()

@type destination() :: :actual | :expected

filetype()

@type filetype() :: :exs | :json | :html

opt()

@type opt() :: {:save_expected, boolean()} | {:format, filetype()}

Functions

assert_snapshot(actual_value, snapshot_name, opts \\ [])

@spec assert_snapshot(any(), String.t(), [opt()]) :: boolean()

Asserts that the actual value matches the expected value saved in a snapshot file. The actual value is always saved (inspect/2 with pretty: true) to a file named actual.exs.

Options

  • :save_expected - Save the actual value as the expected value for the snapshot. This overwrites the existing expected value.
  • :format - Format the actual value in specific format. Currently supports :exs and :json.

format_how_to_update_expected(snapshot_name, filetype)

@spec format_how_to_update_expected(String.t(), filetype()) :: String.t()

format_snapshot_does_not_match(snapshot_name, filetype)

format_snapshot_not_found(snapshot_name, filetype)

load_snapshot!(name, filetype)

@spec load_snapshot!(String.t(), :exs) :: any()
@spec load_snapshot!(String.t(), :json) :: map()
@spec load_snapshot!(String.t(), :html) :: String.t()

save_snapshot(actual_value, name, destination, filetype)

@spec save_snapshot(any(), String.t(), destination(), filetype()) :: :ok

snapshot_path(name, destination, filetype)

@spec snapshot_path(String.t(), destination(), filetype()) :: String.t()