Skip to content

Accepting Changes Automatically #590

Open
@mbechto

Description

@mbechto

Hi,

I am using ApprovalTests.Java for a while now and was wondering whether you would be open to a feature request (or tell me how I can improve my development workflow).

Having done some Rust recently, I am used to the cargo-insta snapshot testing library. One thing I like about insta is, that it displays the diff directly in the terminal where cargo build is executed and you are presented with the option to accept or reject the changes with a key-press (y/n).

With ApprovalTests the diff view - in my case in IntelliJ - opens, which is fine in most cases. But with an increasing number of changed files and diffs, this causes a cascade of many diff windows during each change.

It may be just how I like to do it, but in my daily workflow I like to review all changes in git before I commit. So to me, clicking all those diff windows feels tedious - where I would just press "y" in insta.

I thought about automating this process by scripting it, something along the lines of for f in *.received.* ; do mv "$f" "${f/.received/.approved}"; done but this feels a little awkward.

Proposal: Add a convenience feature to accept all changes automatically.

Implementation idea: A system property e.g. provided at build time:

mvn verify -Dapprovaltests.acceptAllChanges=true

or environment variable

APPROVALTESTS_ACCEPT_ALL_CHANGES=true mvn verify

that causes ApprovalTests to override the *.approved.* files with their changes without prompting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions