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
I have come back to this library after a while and I swear when I first encountered it back in October 2019, prompted by learning about jest in when learning Vue. Js, there was a capability to exclude (or ignore the value of) certain fields from the snapshot check.
I can't find any notion of this.
I think it would be a useful feature to be able to exclude fields which change.
For example. And the wording and specifics of my method is to illustrate the point and is not that important.
[Fact]
public void MyTest()
{
var myUser = _userService.CreateUser(new User() );
myUser.ShouldMatchSnapshot()
.Exclude((user) => user.Id)
}
I think if you were able to load the snapshot and apply the exclusion and apply the exclusion to the
In memory object and then compare, this might not be too hard to achieve. The typing would be provided by the type available coming into the first extension method and then maybe simply using anonymous types or using reflection you could skip over the field to exclude. I think it might get harder with nested properties though.
EDIT: actually the concept of exclusion Is probably the wrong
Or different thing to what I am after it's more like ignoring the value of a field or defaulting a a changeable field to a fixed value....
I guess a workaround to this would be to do the exclusion/defaulting on the model we want the snapshot of and Then create the snapshot.
So do what I said about exclusion/ignore but in place and then create the snapshot.. I could hide this in my own set of wrapper methods for the time being I guess.
The text was updated successfully, but these errors were encountered:
Sorry about the super late reply. I've had this kind of a feature in mind for a while but didn't feel like it needed to be Snapper as like you mentioned the user can easily pre-process their own object.
I saw the PR you made #78 and the implementation is quite separate from Snapper.
Or different thing to what I am after it's more like ignoring the value of a field or defaulting a a changeable field to a fixed value....
This is what I originally had in mind but I decided to hold off on it for now for two reasons.
I haven't seen enough demand for this feature
I would like Snapper to encourage people to make deterministic tests. If there are parts of the snapshot changing, it violates that and can give a false sense of security to ones tests.
I have come back to this library after a while and I swear when I first encountered it back in October 2019, prompted by learning about jest in when learning Vue. Js, there was a capability to exclude (or ignore the value of) certain fields from the snapshot check.
I can't find any notion of this.
I think it would be a useful feature to be able to exclude fields which change.
For example. And the wording and specifics of my method is to illustrate the point and is not that important.
[Fact]
public void MyTest()
{
var myUser = _userService.CreateUser(new User() );
myUser.ShouldMatchSnapshot()
.Exclude((user) => user.Id)
}
I think if you were able to load the snapshot and apply the exclusion and apply the exclusion to the
In memory object and then compare, this might not be too hard to achieve. The typing would be provided by the type available coming into the first extension method and then maybe simply using anonymous types or using reflection you could skip over the field to exclude. I think it might get harder with nested properties though.
EDIT: actually the concept of exclusion Is probably the wrong
Or different thing to what I am after it's more like ignoring the value of a field or defaulting a a changeable field to a fixed value....
I guess a workaround to this would be to do the exclusion/defaulting on the model we want the snapshot of and Then create the snapshot.
So do what I said about exclusion/ignore but in place and then create the snapshot.. I could hide this in my own set of wrapper methods for the time being I guess.
The text was updated successfully, but these errors were encountered: