If you are having trouble getting tests running reproducibly, you might need to use a "scrubber" to convert the non-deterministic text to something stable.
Fundamentally, a scrubber is function that takes a string and returns a string. You can create ones by passing in a function or a lambda. We also have some pre-made ones for your convenience.
You can scrub text manually, before passing it in to Approvals::verify(), but the preferred method is to include a Scrubber as an option.
Approvals::verify(input, Options().withScrubber(scrubber));
There are several patterns that are commonly used when scrubbing:
- Replace troublesome text
- Replace troublesome text, tracking duplicates
- Combining scrubbers
- Deleting troublesome lines