go-approval-tests icon indicating copy to clipboard operation
go-approval-tests copied to clipboard

Add an easy bulk approve-all method

Open davidalpert opened this issue 1 year ago • 1 comments

While working with approval tests it is sometimes the case that one code change can result in many similar changes to a set of previously baselined approved files.

In this scenario it can be simpler to bulk approve all and use source control tools to scan the approved files for diffs rather than to review each received vs approval one by one in the configured diff reporter.

It would be helpful to add a mechanism to bulk approve all verifications, either as another verifyOptions helper https://github.com/approvals/go-approval-tests/blob/32d5677069bd623f06e909e11474d27400539dae/approvals.go#L270-L273

Or as an environment variable.

In some ruby-based approval use cases, for example, I have patched in an optional environment variable APPROVE_ALL; when set to something non-empty (e.g. 1 or 'true') all received diffs are approved.

davidalpert avatar Jan 28 '24 15:01 davidalpert

a possible workaround (this is what I usually do) :

 find . -name "*received.txt" -exec bash -c 'mv $0 ${0/received/approved}' {} \;

tyrcho avatar May 13 '24 06:05 tyrcho