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.
I'd like to take snapshots of image files, namely PNG files.
Describe the solution you'd like
I'd like to be able to match on a System.Drawing.Image object or byte array. Also, be able to easily change the file extension of the snap file to png, or whatever image format I'd like.
Maybe something like myImageByteArray.MatchSnaphot(ImageFormat.Png);
Describe alternatives you've considered
I've tried just taking a snap shot of the byte array of the image. However these are not the same times that get stored to the snap file. Extra formatting is added.
My workaround is just to use the mangled byte array as the snap file and I also write out the PNG file to the snapshot folder too so that developers or any other tool can open the image file.
var snapFilename = Snapshot.FullName();
using (var image = Image.FromStream(new MemoryStream(myImageByteArray)))
{
var pngFilename = new FileInfo(Path.Combine(snapFilename.FolderPath, "__snapshots__", $"{nameof(MyTestClass)}_{nameof(MyTestMethod)}_as") + ".png");
image.Save(pngFilename.FullName, ImageFormat.Png);
}
Additional context
My current use case is PNG files. Although, I can see a use case for PDF files too (in order to compare report outputs).
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'd like to take snapshots of image files, namely PNG files.
Describe the solution you'd like
I'd like to be able to match on a
System.Drawing.Image
object or byte array. Also, be able to easily change the file extension of the snap file to png, or whatever image format I'd like.Maybe something like
myImageByteArray.MatchSnaphot(ImageFormat.Png);
Describe alternatives you've considered
I've tried just taking a snap shot of the byte array of the image. However these are not the same times that get stored to the snap file. Extra formatting is added.
My workaround is just to use the mangled byte array as the snap file and I also write out the PNG file to the snapshot folder too so that developers or any other tool can open the image file.
Additional context
My current use case is PNG files. Although, I can see a use case for PDF files too (in order to compare report outputs).
The text was updated successfully, but these errors were encountered: