View Source Heyya.SnapshotUtil (heyya v1.0.0)
Heyya.SnapshotUtil
module provides helper methods that make it easier to write snapshot tests.
Summary
Functions
Gets the directory to store snapshot files for the test.
Gets the stored snapshot for the given macro environment.
Should the snapshot be overridden? if it doesn't match.
Functions
@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 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?() :: boolean()
Should the snapshot be overridden? if it doesn't match.
Returns
True if the snapshot should be overridden, denoted by the environment variable HEYYA_OVERRIDE
. The value can be true
, 1
, yes
, or YES
.
False if the snapshot should not be overridden