prefer-snapshot-hint
Added in v0.9.4Configuration
Rule Details
Prefer including a descriptive hint with external snapshots. Hints make snapshots easier to identify during review and updates.
The rule checks toMatchSnapshot and toThrowErrorMatchingSnapshot. Inline snapshots are ignored. The default "multi" mode requires hints in groups containing multiple external snapshot assertions; "always" requires a hint on every external snapshot assertion. Function expressions, arrow functions, methods, and accessors establish groups that include nested helper expressions, while test and suite registrations reset the grouping boundary. Function declarations do not establish separate groups.
For toMatchSnapshot, a single string literal or template without interpolation counts as a hint, and two arguments count as properties plus a hint. A single variable or interpolated template is reported, regardless of its type. toThrowErrorMatchingSnapshot accepts a single hint argument. This rule does not require type information or provide fixes.