Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto update for SCM checked in snapshots #50

Open
skuzzle opened this issue Dec 20, 2022 · 0 comments
Open

Auto update for SCM checked in snapshots #50

skuzzle opened this issue Dec 20, 2022 · 0 comments

Comments

@skuzzle
Copy link
Owner

skuzzle commented Dec 20, 2022

Updating snapshots with the latest actual result might be cumbersome. You either need to rerun the whole test suite again with @ForceUpdateSnapshots and then another time without the annotation. Or you need to manually update the snapshot files.
Since 1.7.0 you could enable @SnapshotTestOptions(alwaysPersistActualResult = true). This will always write the latest actual result as a sibling file next to the actual snapshot. Then you could just delete the snapshot and rename the created .snapshot_actual file to .snapshot. This would update the snapshot to the latest actual result without having to rerun the test suite.

If snapshot files are already checked into the SCM, we could consider the following auto update workflow:

  1. If we find a difference to the current snapshot AND the snapshot is checked into SCM AND the snapshot is not marked modified (in terms of git status), then we can auto-update the persisted snapshot with the current actual result. The snapshot file will subsequently be marked modified in git status and the user needs to confirm these modifications by committing the file.
  2. If a snapshot file is marked modified by the SCM we can assume that it has been auto-updated by a previous test run. In that case we always fail the test. The user will need to commit the file in order to clear its status and to confirm the modifications to the snapshot file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant