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
Describe the bug
Within a single async method, using multiple snapshots with different names does not work.
To Reproduce
[TestMethod]
public async Task TestFoo()
{
var something = new Foo();
var fullName1 = Snapshot.FullName(new SnapshotNameExtension("GetFoo"));
var fullName2 = Snapshot.FullName(new SnapshotNameExtension("GetBar"));
something.GetFoo().MatchSnapshot(fullName1);
something.GetBar().MatchSnapshot(fullName2); // BOOM - fails since fullname 2 is identical to fullName1
}
Expected behavior
Two different snapshots should be created and verified.
Desktop (please complete the following information):
[TestMethod]
public async Task TestFoo()
{
var something = new Foo();
var fullName1 = Snapshot.FullName(new SnapshotNameExtension("GetFoo"));
something.GetFoo().MatchSnapshot(fullName1);
var fullName2 = Snapshot.FullName(new SnapshotNameExtension("GetBar"));
something.GetBar().MatchSnapshot(fullName2);
}
Describe the bug
Within a single async method, using multiple snapshots with different names does not work.
To Reproduce
Expected behavior
Two different snapshots should be created and verified.
Desktop (please complete the following information):
Additional context
Using MSTest
The problem is that the entire snapshot-naming info is cached in an
AsyncLocal
, therfore the second Snapshot.FullName has no effect since this cache is already initialized:https://github.com/SwissLife-OSS/snapshooter/blob/94f9c77703a05e0d03b02aba9adb68d655fab820/src/Snapshooter.MSTest/Snapshot.cs#L15C5-L17C75
The text was updated successfully, but these errors were encountered: