Skip to content

Conversation

bhokaremoin
Copy link
Contributor

@bhokaremoin bhokaremoin commented Jul 30, 2025

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.

@bhokaremoin bhokaremoin requested a review from a team as a code owner July 30, 2025 11:23
@bhokaremoin bhokaremoin changed the title Adding support for ignore canvas serialization errors ✨ Adding support for ignoreCanvasSerializationErrors Jul 30, 2025
@bhokaremoin bhokaremoin added the ✨ enhancement New feature or request label Jul 30, 2025
@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 11:41
Copilot

This comment was marked as outdated.

@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 11:45
Copilot

This comment was marked as outdated.

@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 11:51
Copilot

This comment was marked as outdated.

@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 11:58
Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 12:00
Copilot

This comment was marked as outdated.

bhokaremoin and others added 3 commits July 30, 2025 17:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bhokaremoin bhokaremoin requested a review from Copilot July 30, 2025 12:05
Copy link
Contributor

@Copilot Copilot AI left a 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 option that can be configured either at the snapshot level or globally in the Percy configuration.

  • Introduces a new helper function ignoreCanvasSerializationErrors that resolves the option value from either snapshot options or global config
  • Updates the DOM serialization process to pass the ignoreCanvasSerializationErrors flag to the PercyDOM.serialize method
  • Adds comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
index.js Adds the ignoreCanvasSerializationErrors helper function and updates DOM serialization to use it
test/index.test.mjs Adds comprehensive test coverage for the new canvas serialization error handling functionality
Comments suppressed due to low confidence (3)

test/index.test.mjs:3

  • The import statement adds ignoreCanvasSerializationErrors but there are no integration tests verifying that percySnapshot properly uses this function internally. Consider adding a test that verifies the integration between percySnapshot and ignoreCanvasSerializationErrors.
import percySnapshot, { ignoreCanvasSerializationErrors } from '../index.js';

test/index.test.mjs:609

  • This test doesn't verify the scenario where options.ignoreCanvasSerializationErrors is explicitly undefined vs when the property doesn't exist. The function uses optional chaining, so both cases should be tested to ensure proper fallback behavior.
  it('should fall back to utils.percy.config.snapshot.ignoreCanvasSerializationErrors when options value is undefined', () => {

test/index.test.mjs:623

  • This test creates a config object with an empty snapshot property but doesn't test the case where utils.percy.config.snapshot itself is undefined or null. Consider adding a test case where the entire config path is missing.
  it('should return false when both options and config are undefined', () => {

…github.com:percy/percy-selenium-js into adding-support-for-ignoreCanvasSerializationErrors
@bhokaremoin bhokaremoin force-pushed the adding-support-for-ignoreCanvasSerializationErrors branch from 56e4b02 to e935175 Compare July 31, 2025 10:04
@bhokaremoin bhokaremoin merged commit 5c816c6 into master Aug 1, 2025
10 checks passed
@bhokaremoin bhokaremoin deleted the adding-support-for-ignoreCanvasSerializationErrors branch August 1, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants