ApprovalTests.Java icon indicating copy to clipboard operation
ApprovalTests.Java copied to clipboard

Support for image approvals based on a similarity percentage threshold

Open vinaysshenoy opened this issue 6 years ago • 3 comments

I had a use-case where I was refactoring a tool that was used for generating PDFs (with Apache PDFBox). I used approval tests to verify the images rendered using the PDFs as approvals. However, there was a problem where the renderer would generate slightly different images on different platforms. This caused problems where I had to create new approvals every time I changed the system I was working on, as well as won't work well with CI.

To solve this, I wrote a different image approver using an image similarity check and the gist is available HERE. This is written in Kotlin, and would be easily portable to Java. I'd love to contribute this back to the project. Would this be something that you'd like to get into the project? I can raise a PR if so.

vinaysshenoy avatar Oct 02 '19 13:10 vinaysshenoy

I have just encuntered this very usecase. We attempted to use AwtApprovals for a PDF rendered to an image via PDFBox. It works fine locally but fails in CI, very possibly due to "irrelevant" rendering differences. Being able to set a threshold for an image match would be most welcome.

AndrzejProchyra avatar Nov 28 '23 08:11 AndrzejProchyra

I set a reminder so that I hopefully remember next Monday when we get together and work on ApprovalTests again. Let's see what we can do about this issue :)

LarsEckart avatar Nov 28 '23 09:11 LarsEckart

yes, we would like to take a look at, but also remember that machine specific namers help for this.

isidore avatar Dec 04 '23 17:12 isidore