Skip to content

chore(deps)(deps-dev): bump pixelmatch from 5.3.0 to 7.2.0#1437

Merged
Saksham-Sirohi merged 6 commits into
fossasia:devfrom
tonypzy:fix/pixelmatch-v7-esm
Jun 11, 2026
Merged

chore(deps)(deps-dev): bump pixelmatch from 5.3.0 to 7.2.0#1437
Saksham-Sirohi merged 6 commits into
fossasia:devfrom
tonypzy:fix/pixelmatch-v7-esm

Conversation

@tonypzy

@tonypzy tonypzy commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Changed to

const pixelmatch = require('pixelmatch').default;

to support V7 since in V7, require('pixelmatch') returns an unexpected object, not an expected pixelmatech function.

The advantages of upgrading pixelmatech from 5.3.0 to 7.2.0:

  • Significantly improved the speed of diff image generation, making CI tests run much faster.
  • Improve the robustness of code

Motivation and Context

Take over #1405

How Has This Been Tested?

N/A

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactor or cleanup (changes to existing code for improved readability or performance)

Checklist:

  • I adapted the version number under py/visdom/VERSION according to Semantic Versioning
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Summary by Sourcery

Update visual regression testing setup to align with the latest pixelmatch release and stabilize screenshot diffs.

Bug Fixes:

  • Ensure pixelmatch is correctly imported when exposed as a default export to prevent visual test failures.
  • Disable pixelmatch's checkerboard mode in Cypress screenshot comparisons to avoid false-positive diffs from UI changes.

Enhancements:

  • Upgrade the pixelmatch dev dependency from 5.3.0 to 7.2.0 for visual regression tests.

dependabot Bot and others added 2 commits June 8, 2026 12:52
Bumps [pixelmatch](https://github.com/mapbox/pixelmatch) from 5.3.0 to 7.2.0.
- [Release notes](https://github.com/mapbox/pixelmatch/releases)
- [Commits](mapbox/pixelmatch@v5.3.0...v7.2.0)

---
updated-dependencies:
- dependency-name: pixelmatch
  dependency-version: 7.2.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@sourcery-ai

sourcery-ai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the visual regression test setup to work with pixelmatch v7 by adjusting the import pattern and disabling checkerboard mode while bumping the pixelmatch dev dependency version and regenerating the lockfile.

Sequence diagram for updated pixelmatch usage in visual regression tests

sequenceDiagram
    participant Cypress
    participant CypressPlugin as cypress/plugins/index_js
    participant pixelmatch

    Cypress->>CypressPlugin: invoke compareSnapshots task
    CypressPlugin->>pixelmatch: pixelmatch(img1, img2, diff, width, height, { threshold: appliedThreshold, checkerboard: false })
    pixelmatch-->>CypressPlugin: diffPixelCount
    CypressPlugin-->>Cypress: diffPixelCount
Loading

File-Level Changes

Change Details Files
Update pixelmatch integration in Cypress visual regression plugin for compatibility with v7 and disable checkerboard artifacts.
  • Change pixelmatch import to use the default export when present, falling back to CommonJS require for backward compatibility.
  • Pass a pixelmatch options object including threshold and checkerboard: false to stabilize visual regression output.
cypress/plugins/index.js
Bump pixelmatch dev dependency to v7 and refresh lockfile.
  • Update pixelmatch version range from ^5.3.0 to ^7.2.0 in devDependencies.
  • Regenerate yarn.lock to resolve pixelmatch and related transitive dependencies for the new version.
package.json
yarn.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • The const pixelmatch = require('pixelmatch').default || require('pixelmatch'); line will execute require('pixelmatch') twice; consider requiring once (e.g., assign to a temp variable and then use .default || on that) to avoid redundant module loading.
  • Since disabling checkerboard changes the behavior of the visual diffing, it would help future readers to add an inline comment explaining why this is forced to false rather than being configurable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `const pixelmatch = require('pixelmatch').default || require('pixelmatch');` line will execute `require('pixelmatch')` twice; consider requiring once (e.g., assign to a temp variable and then use `.default ||` on that) to avoid redundant module loading.
- Since disabling `checkerboard` changes the behavior of the visual diffing, it would help future readers to add an inline comment explaining why this is forced to `false` rather than being configurable.

## Individual Comments

### Comment 1
<location path="cypress/plugins/index.js" line_range="20-23" />
<code_context>
 const fs = require('fs');
 const path = require('path');
-const pixelmatch = require('pixelmatch');
+const pixelmatch = require('pixelmatch').default || require('pixelmatch');
 const PNG = require('pngjs').PNG;

</code_context>
<issue_to_address>
**suggestion:** Avoid requiring the same module twice and reuse the loaded module instead.

This calls `require('pixelmatch')` twice, which is unnecessary and could trigger module init side effects twice. Instead, assign the module once and derive the export:

```js
const pixelmatchModule = require('pixelmatch');
const pixelmatch = pixelmatchModule.default || pixelmatchModule;
```

```suggestion
const fs = require('fs');
const path = require('path');
const pixelmatchModule = require('pixelmatch');
const pixelmatch = pixelmatchModule.default || pixelmatchModule;
const PNG = require('pngjs').PNG;
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread cypress/plugins/index.js
@tonypzy

tonypzy commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@Saksham-Sirohi Saksham-Sirohi merged commit 419c551 into fossasia:dev Jun 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants