View Source Heyya.SnapshotTest (heyya v0.7.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.
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.
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.
@spec directory(Macro.Env.t()) :: String.t()
Gets the directory to store snapshot files for the test.
Parameters
- env: The macro environment which contains metadata about the test file.
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
- env: The macro environment which contains metadata about the test module and function.
Returns
The stored snapshot as a binary, or empty binary if no snapshot exists.
@spec override!(Macro.Env.t(), binary()) :: :ok
@spec override?() :: boolean()