-
Notifications
You must be signed in to change notification settings - Fork 52
✨ Adding support for ignoreCanvasSerializationErrors #1948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for making canvas serialization fail-safe by introducing an ignoreCanvasSerializationErrors
configuration option. When enabled, canvas serialization errors are caught and handled gracefully by rendering a fallback broken image instead of throwing errors.
- Adds
ignoreCanvasSerializationErrors
configuration option at both global config and snapshot levels - Modifies canvas serialization to catch errors and create fallback image elements when the flag is enabled
- Refactors canvas serialization code to extract image element creation into a reusable helper function
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/core/src/config.js | Adds schema definition for the new ignoreCanvasSerializationErrors boolean configuration option |
packages/core/src/page.js | Passes the ignoreCanvasSerializationErrors option through the snapshot capture pipeline |
packages/core/src/discovery.js | Adds debug logging for the new configuration option |
packages/dom/src/serialize-dom.js | Extracts and passes the ignoreCanvasSerializationErrors option to the serialization context |
packages/dom/src/serialize-canvas.js | Refactors canvas serialization to handle errors gracefully and create fallback images when flag is enabled |
packages/dom/test/serialize-dom.test.js | Adds tests for the new error handling behavior in DOM serialization |
packages/dom/test/serialize-canvas.test.js | Adds comprehensive tests for canvas error handling and fallback image creation |
packages/core/test/percy.test.js | Updates test expectations to include the new configuration option |
Comments suppressed due to low confidence (1)
packages/dom/test/serialize-dom.test.js:471
- This test is identical to the previous test case 'ignores canvas serialization errors when flag is enabled'. The test name suggests it should verify the flag is picked from options, but it doesn't test anything different or demonstrate how options are prioritized.
it('picks ignoreCanvasSerializationErrors flag from options', () => {
Added support for making canvas serialization fail-safe.
Passing
ignoreCanvasSerializationErrors
in snapshot options or at global config. ignore any errors that occur during canvas serialization. And instead renders a broken Img.