View Source Heyya.SnapshotCase (heyya v1.0.0)

Heyya.SnapshotCase 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.

Complex Tests Made Easy

Suppose you have a component button with a color and and icon. You want to test that the correct css class is applied to the whole dom tree. Instead assert that the dom tree is functionally equivalent to the expected output.

component_snapshot_test "Eiffel 65" do
  assigns = %{}

  ~H|<.button phx-click="click" class="bg-blue-500">Click me</.button>|
end

Change Tests Faster

Any changes to that would require changes to the test are easily updated by running the tests and updating the snapshots. This happens by setting the environment variable HEYYA_OVERRIDE to true or 1.

HEYYA_OVERRIDE=true mix test

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.

Functions

Link to this macro

__using__(opts)

View Source (macro)

Wire up the module to prepare for snapshot testing.

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.

Link to this macro

inner_test(expr)

View Source (macro)