Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 1.94 KB

Scrubbers.md

File metadata and controls

59 lines (40 loc) · 1.94 KB

Scrubbers

Contents

Introduction

Scrubber Overview

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.

Interface

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.

How to use Scrubbers

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));

snippet source | anchor

Scrubber concepts

There are several patterns that are commonly used when scrubbing:

  • Replace troublesome text
  • Replace troublesome text, tracking duplicates
  • Combining scrubbers
  • Deleting troublesome lines

See also


Back to User Guide