You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The AssertMatchOperator is a very useful tool for applying custom validation logic to particular fields in a result. However, the current implementation exposes only the actual result values, instead of also exposing the expected result values. This makes it difficult to perform validations that use the expected value, but are not just strict equality comparisons.
A simple example of something that's currently difficult to do: Verify that a given field in a result has the same first N characters as the corresponding field in a snapshot file.
Describe the solution you'd like ExecuteMatch in AssertMatchOperator already has access to an expectedSnapshotData, it just doesn't do anything with it. I'd like to be able to define an assert function that takes both actual and expected field options and performs assertions across the two.
Describe alternatives you've considered
It's possible to implement this sort of logic in test code rather than using Snapshooter directly, but that loses many of the things that make Snapshooter so useful, like automatic mismatch handling.
It's also possible to do something similar using the existing AssertMatchOperator, but that requires maintaining a source of truth for expected values that's separate from the existing .snap file.
Additional context
This seems like a simple change. I'm happy to make it myself, but perhaps the maintainers here would prefer a different approach for solving this problem.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The
AssertMatchOperator
is a very useful tool for applying custom validation logic to particular fields in a result. However, the current implementation exposes only the actual result values, instead of also exposing the expected result values. This makes it difficult to perform validations that use the expected value, but are not just strict equality comparisons.A simple example of something that's currently difficult to do: Verify that a given field in a result has the same first N characters as the corresponding field in a snapshot file.
Describe the solution you'd like
ExecuteMatch
inAssertMatchOperator
already has access to anexpectedSnapshotData
, it just doesn't do anything with it. I'd like to be able to define an assert function that takes bothactual
andexpected
field options and performs assertions across the two.Describe alternatives you've considered
It's possible to implement this sort of logic in test code rather than using Snapshooter directly, but that loses many of the things that make Snapshooter so useful, like automatic mismatch handling.
It's also possible to do something similar using the existing
AssertMatchOperator
, but that requires maintaining a source of truth for expected values that's separate from the existing.snap
file.Additional context
This seems like a simple change. I'm happy to make it myself, but perhaps the maintainers here would prefer a different approach for solving this problem.
The text was updated successfully, but these errors were encountered: