Skip to content

CLI Mode where snapshots must be approved before they are saved #1798

@suchipi

Description

@suchipi

Do you want to request a feature or report a bug?

Feature Request

What is the current behavior?

I sometimes like to write my tests before writing my implementation (TDD/BDD/etc). Occasionally while doing this, I need to assert some large output that I feel is best handled using a snapshot. However, I don't want to write the snapshot to disk until the code has been implemented, because I'll have to keep updating it. So I write this a lot:

expect(actual).toEqual("SNAPSHOT")

I use this as a placeholder that I expect to fail, and then once I'm ready to write the snapshot, I change it to the toMatchSnapshot matcher, then go review the snapshot (but if it was wrong, then I need to either keep updating it, or delete the snapshot).

It'd be nice if the watcher had a mode where it didn't write snapshots until I approved them, and if I didn't approve them by the time tests had to run again, it would move on without writing anything. As a bonus, I think requiring approval would help encourage me to verify my snapshot content rather than writing whatever the current behavior is and calling it good, at risk that it's not (which is very easy to do with snapshots right now).

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

N/A

What is the expected behavior?

N/A

Run Jest again with --debug and provide the full configuration it prints. Please mention your node and npm version and operating system.

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions