Source code rewriting for snap! inline snapshots.
Uses rewrite-clj to parse, locate, and modify snap! calls in source files while preserving formatting and comments.
Source code rewriting for snap! inline snapshots. Uses rewrite-clj to parse, locate, and modify snap! calls in source files while preserving formatting and comments.
(add-expected-value! file-path line expected-value)(add-expected-value! file-path line expected-value value-sig)Add or update the expected value in a snap! call.
Arguments:
Returns:
Add or update the expected value in a snap! call. Arguments: - file-path: Absolute path to the source file - line: Line number of the snap! call (compile-time, pre-edit) - expected-value: The value to insert as expected - value-sig (optional): canonical string of the value expression, used to locate the call regardless of line drift. When omitted or nil, the call is located by line number alone. Returns: - :updated if the expected value was updated - :inserted if a new expected value was inserted - :not-found if the snap! call wasn't found - :error if an error occurred
(find-all-snap!-calls file-path)Find all snap! calls in a file.
Returns a sequence of maps with:
Find all snap! calls in a file. Returns a sequence of maps with: - :line - Line number - :column - Column number - :has-expected? - Whether it has an expected value - :value - The value expression (as string) - :expected - The expected value expression (if present, as string)
(find-all-snap-calls file-path)Find all snap and snap! calls in a file.
Returns a sequence of maps:
Throws ex-info if the file cannot be parsed.
Find all snap and snap! calls in a file.
Returns a sequence of maps:
- {:type :snap :key <keyword> :line <n>} for snap calls (the :key entry is
present when the first argument is a keyword literal)
- {:type :snap! :line <n>} for snap! calls
Throws ex-info if the file cannot be parsed.(remove-expected-value! file-path line)Remove the expected value from a snap! call.
This converts: (snap! value expected) to: (snap! value)
Useful for resetting a snapshot.
Remove the expected value from a snap! call. This converts: (snap! value expected) to: (snap! value) Useful for resetting a snapshot.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |