View Source Heyya.SnapshotTest (heyya v0.5.1)

Heyya.SnapshotTest allows for fast snapshot testing of Phoenix components. Snapshot testing components is a fast and easy way to ensure that they work and produce what they expected to produce without having to hand write assertions.

Link to this section Summary

Functions

Wire up the module to prepare for snapshot testing.

A named component snapshot test

A named component snapshot test, where context is passed through.

Gets the directory to store snapshot files for the test.

Gets the stored snapshot for the given macro environment.

Link to this section Functions

Link to this macro

__using__(opts)

View Source (macro)

Wire up the module to prepare for snapshot testing.

Link to this function

compare_html(snapshot_value, rendered_value)

View Source
@spec compare_html(binary(), binary()) :: boolean()
Link to this macro

component_snapshot_test(name, list)

View Source (macro)

A named component snapshot test

Link to this macro

component_snapshot_test(name, context, list)

View Source (macro)

A named component snapshot test, where context is passed through.

@spec directory(Macro.Env.t()) :: String.t()

Gets the directory to store snapshot files for the test.

parameters

Parameters

  • env: The macro environment which contains metadata about the test file.

returns

Returns

The directory path as a binary where snapshots should be stored.

@spec filename(Macro.Env.t()) :: String.t()
@spec get_snapshot(Macro.Env.t()) :: binary()

Gets the stored snapshot for the given macro environment.

This looks up the snapshot file path and name based on the environment, reads the file contents, and returns the snapshot.

If there is no snapshot file yet, returns an empty binary.

parameters

Parameters

  • env: The macro environment which contains metadata about the test module and function.

returns

Returns

The stored snapshot as a binary, or empty binary if no snapshot exists.

Link to this macro

inner_test(expr)

View Source (macro)
@spec override!(Macro.Env.t(), binary()) :: :ok
@spec override?() :: boolean()