faberNovel / SDWebImageMockPlugin

SDWebImageMockPlugin makes possible the creation of snapshot testing with views using SDWebImage to configure images.
MIT License
6 stars 0 forks source link

Plugin is not working properly with SDWebImageSwiftUI versions >2.1.0 #2

Open kpacholak opened 1 year ago

kpacholak commented 1 year ago

Hi! I've just discovered that if you update SDWebImageSwiftUI to higher version than 2.1.0, snapshots (swift snapshot-testing) are no longer properly generated. I can't see any images cached by SDWebImageMockPlugin.

2.1.0 is the last version which works for me.

Can anyone check and confirm that? All the best! Krzysztof

alexandre-pod commented 1 year ago

Hi, thanks for raising this issue with latest version of SDWebImageSwiftUI. I gave it a try and I find the same issues that you had, the images are not rendered on the snapshots.

By looking at the code of SDWebImageSwiftUI I found that the changes in that pull request is causing the issue: https://github.com/SDWebImage/SDWebImageSwiftUI/pull/232. The backport behavior is adding a DispatchQueue.main.async (this one) between the appearance of the WebImage and the loading of the image, and this is preventing the snapshot to be taken with the image.

I can suggest you a workaround to make your tests pass (if it works for you): 11abca6694fdc32fde64876b00c80930ad89f188

Let me know if it helped you.

kpacholak commented 1 year ago

Hi Alexandre! I can confirm - your workaround works Executed 1 test, with 0 failures (0 unexpected) in 0.246 (0.250) seconds 👌

Are you planning to provide a patch?