cypress-plugin-visual-regression-diff: Invalid PNG error
Describe the bug When capturing screenshots I intermittently get an “Invalid PNG” error in the console.
TypeError: Invalid PNG
at Object.addMetadata (C:\dev\cg-react-components\node_modules\meta-png\dist\meta-png.umd.js:1:886)
at addPNGMetadata (C:\dev\cg-react-components\node_modules\@frsource\cypress-plugin-visual-regression-diff\src\image.utils.ts:12:3)
at writePNG (C:\dev\cg-react-components\node_modules\@frsource\cypress-plugin-visual-regression-diff\src\image.utils.ts:23:5)
at compareImagesTask (C:\dev\cg-react-components\node_modules\@frsource\cypress-plugin-visual-regression-diff\src\task.hook.ts:157:5)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
To Reproduce Steps to reproduce the behavior:
The issue is intermittent. A test might pass one time and fail another. All my tests are component tests. The subject of the screenshot does not seem to matter.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots capture without error
Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following information:
- Package version: 3.1.1
- OS and version: Windows 10
- Browser and version Chrome/Firefox
- Cypress version 10.11.0
Additional context Add any other context about the problem here.
I think the problem is due to the recently added cleanup functionality using the metadata. I have logged out the PNG buffer and there is data there.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 25 (12 by maintainers)
Thank you all for the messages, we’re really having quite intense issue-fixing process going on here 😄 ❤️
@dhulme I’ve created a PR with this fix on
meta-pnglibrary repo. Last time its author was really quick and released new version the same day I’ve created a PR. So, hopefullymeta-pngwill get released with a fix soon and I’ll be able ship it to you this week.If that won’t help for @menelikw and @xibman I’ll do one more round of trying to reproduce it (@menelikw then your repo would be super useful 🙏 ).
I’ll keep you updated
@menelikw Hey,
Yes, it’s a separate issue - something not related to this ticket.
But I see it was reported today already: https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/issues/184 Please follow that report for updates
@FRSgit Thanks a lot i’ve just done the update, it work well !
Yeah I’ll do that this evening uk time.
+1 for this bug.
Test failed both in headless mode and with chrome browser but not always.
Both screenshots are created:
More complete stack trace