Support for image approvals based on a similarity percentage threshold
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.
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.
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 :)
yes, we would like to take a look at, but also remember that machine specific namers help for this.