franiglesias / golden

Golang Library for snapshot testing
MIT License
3 stars 2 forks source link

Approvals #2

Closed franiglesias closed 9 months ago

franiglesias commented 9 months ago

Provide a way to force the approval of a snapshot before it can be used as matching criteria.

In "snapshot mode", a snapshot that is created for first time is supposed to represent the behaviour of the subject under test. In "approval mode", a snapshot that is created for first time has to wait to be approved by a human actor before being used as matching criteria.

Known approaches

Proposal

Do this in the test

First, you execute the test in "approval mode", so test will never pass.

golden.ToApprove(t, subject)

Once you are happy with the output, back to verify

golden.Verify(t, subject)

Pros

Cons

API

golden.ToApprove(t, subject)

This will kind of a decorator around Verify. It will set a flag so the system can decide if it needs to compare snapshot and subject. Snapshot creation has to be forced even if previous snapshot exists.

A reminder to approve the snapshot can be added to the report.

franiglesias commented 9 months ago

Ready