{"id":14967476,"url":"https://github.com/dword-design/jest-image-matcher","last_synced_at":"2025-12-14T15:12:57.210Z","repository":{"id":40567703,"uuid":"340687475","full_name":"dword-design/jest-image-matcher","owner":"dword-design","description":"A Jest matcher for image comparisons based on pixelmatch. Can also be used with Mocha. Useful for visual regression testing.","archived":false,"fork":false,"pushed_at":"2025-01-19T05:00:19.000Z","size":1825,"stargazers_count":4,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T10:23:55.500Z","etag":null,"topics":["assert","compare","comparison","expect","extend","image","jest","match","matcher","mocha","regression","visual"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dword-design.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["buymeacoffee.com/dword","paypal.me/SebastianLandwehr"],"github":"dword-design","patreon":"dworddesign"}},"created_at":"2021-02-20T15:31:01.000Z","updated_at":"2025-01-19T05:00:21.000Z","dependencies_parsed_at":"2023-02-08T08:15:59.600Z","dependency_job_id":"5b52e643-69d4-4123-ad1e-b3270ee4b455","html_url":"https://github.com/dword-design/jest-image-matcher","commit_stats":{"total_commits":139,"total_committers":8,"mean_commits":17.375,"dds":0.6330935251798562,"last_synced_commit":"23412352c0d80da3f707bb90dd3ffd47926bf846"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fjest-image-matcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fjest-image-matcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fjest-image-matcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dword-design%2Fjest-image-matcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dword-design","download_url":"https://codeload.github.com/dword-design/jest-image-matcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238207641,"owners_count":19434095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assert","compare","comparison","expect","extend","image","jest","match","matcher","mocha","regression","visual"],"created_at":"2024-09-24T13:38:06.883Z","updated_at":"2025-12-14T15:12:57.191Z","avatar_url":"https://github.com/dword-design.png","language":"JavaScript","funding_links":["buymeacoffee.com/dword","paypal.me/SebastianLandwehr","https://github.com/sponsors/dword-design","https://patreon.com/dworddesign","https://www.buymeacoffee.com/dword","https://paypal.me/SebastianLandwehr","https://www.patreon.com/dworddesign"],"categories":[],"sub_categories":[],"readme":"\u003c!-- TITLE/ --\u003e\n# jest-image-matcher\n\u003c!-- /TITLE --\u003e\n\n\u003c!-- BADGES/ --\u003e\n\u003cp\u003e\n  \u003ca href=\"https://npmjs.org/package/jest-image-matcher\"\u003e\n    \u003cimg\n      src=\"https://img.shields.io/npm/v/jest-image-matcher.svg\"\n      alt=\"npm version\"\n    \u003e\n  \u003c/a\u003e\u003cimg src=\"https://img.shields.io/badge/os-linux%20%7C%C2%A0macos%20%7C%C2%A0windows-blue\" alt=\"Linux macOS Windows compatible\"\u003e\u003ca href=\"https://github.com/dword-design/jest-image-matcher/actions\"\u003e\n    \u003cimg\n      src=\"https://github.com/dword-design/jest-image-matcher/workflows/build/badge.svg\"\n      alt=\"Build status\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://codecov.io/gh/dword-design/jest-image-matcher\"\u003e\n    \u003cimg\n      src=\"https://codecov.io/gh/dword-design/jest-image-matcher/branch/master/graph/badge.svg\"\n      alt=\"Coverage status\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://david-dm.org/dword-design/jest-image-matcher\"\u003e\n    \u003cimg src=\"https://img.shields.io/david/dword-design/jest-image-matcher\" alt=\"Dependency status\"\u003e\n  \u003c/a\u003e\u003cimg src=\"https://img.shields.io/badge/renovate-enabled-brightgreen\" alt=\"Renovate enabled\"\u003e\u003cbr/\u003e\u003ca href=\"https://gitpod.io/#https://github.com/dword-design/jest-image-matcher\"\u003e\n    \u003cimg\n      src=\"https://gitpod.io/button/open-in-gitpod.svg\"\n      alt=\"Open in Gitpod\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://www.buymeacoffee.com/dword\"\u003e\n    \u003cimg\n      src=\"https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg\"\n      alt=\"Buy Me a Coffee\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://paypal.me/SebastianLandwehr\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/paypal.svg\"\n      alt=\"PayPal\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u003ca href=\"https://www.patreon.com/dworddesign\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/patreon.svg\"\n      alt=\"Patreon\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- /BADGES --\u003e\n\n\u003c!-- DESCRIPTION/ --\u003e\nA Jest matcher for image comparisons based on pixelmatch. Can also be used with Mocha. Useful for visual regression testing.\n\u003c!-- /DESCRIPTION --\u003e\n\nThis package is solely for image comparisons and is inspired by packages like [chai-image](https://www.npmjs.com/package/chai-image). If you want to have snapshot testing, there are packages like [jest-image-snapshot](https://www.npmjs.com/package/jest-image-snapshot).\n\n\u003c!-- INSTALL/ --\u003e\n## Install\n\n```bash\n# npm\n$ npm install jest-image-matcher\n\n# Yarn\n$ yarn add jest-image-matcher\n```\n\u003c!-- /INSTALL --\u003e\n\n## Usage\n\n```js\nimport { toMatchImage } from 'jest-image-matcher'\nimport fs from 'fs'\n\n// register the matcher\nexpect.extend({ toMatchImage })\n\nit('should match', async () =\u003e {\n  // get an image from somewhere as a buffer,\n  // like reading it from the file system\n  const image1 = fs.readFileSync('image1.png')\n  const image2 = fs.readFileSync('image2.png')\n  expect(image1).toMatchImage(image2)\n})\n```\n\nCompare to a file directly:\n```js\nit('should match', () =\u003e {\n  …\n  expect(image).toMatchImage('image.png')\n})\n```\n\nSave the diff to a file if the images do not match:\n```js\nit('should match', () =\u003e {\n  …\n  expect(image).toMatchImage('image.png', { diffPath: 'diff.png' })\n})\n```\n\nOutput the base64 diff image for debugging on CI servers:\n```js\nit('should match', () =\u003e {\n  …\n  expect(image).toMatchImage('image.png', { dumpDiffToConsole: true })\n})\n```\n\nUsage with [puppeteer](https://www.npmjs.com/package/puppeteer):\n```js\nit('should match', async () =\u003e {\n  const screenshot = await page.screenshot()\n  expect(screenshot).toMatchImage('screenshot.png')\n})\n```\n\n\u003c!-- LICENSE/ --\u003e\n## Contribute\n\nAre you missing something or want to contribute? Feel free to file an [issue](https://github.com/dword-design/jest-image-matcher/issues) or a [pull request](https://github.com/dword-design/jest-image-matcher/pulls)! ⚙️\n\n## Support\n\nHey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:\n\n\u003cp\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/dword\"\u003e\n    \u003cimg\n      src=\"https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg\"\n      alt=\"Buy Me a Coffee\"\n      width=\"114\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;If you want to send me a one time donation. The coffee is pretty good 😊.\u003cbr/\u003e\n  \u003ca href=\"https://paypal.me/SebastianLandwehr\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/paypal.svg\"\n      alt=\"PayPal\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;Also for one time donations if you like PayPal.\u003cbr/\u003e\n  \u003ca href=\"https://www.patreon.com/dworddesign\"\u003e\n    \u003cimg\n      src=\"https://sebastianlandwehr.com/images/patreon.svg\"\n      alt=\"Patreon\"\n      width=\"163\"\n    \u003e\n  \u003c/a\u003e\u0026nbsp;Here you can support me regularly, which is great so I can steadily work on projects.\n\u003c/p\u003e\n\nThanks a lot for your support! ❤️\n\n## See also\n\n* [output-files](https://github.com/dword-design/output-files): Output a tree of files and directories by providing an object. Especially useful for testing with real files.\n* [with-local-tmp-dir](https://github.com/dword-design/with-local-tmp-dir): Creates a temporary folder inside cwd, cds inside the folder, runs a function, and removes the folder. Especially useful for testing.\n* [expect-mocha-image-snapshot](https://github.com/dword-design/expect-mocha-image-snapshot): A wrapper around jest-image-snapshot that makes it compatible to Mocha.\n* [unify-mocha-output](https://github.com/dword-design/unify-mocha-output): Adjusts a Mocha output so that it is consistent across platforms and can be used for snapshot testing. Basically adjusts the checkmark symbol and removes time values.\n* [mock-argv](https://github.com/dword-design/mock-argv): Temporarily overrides the command line arguments. This is useful for testing.\n\n## License\n\n[MIT License](https://opensource.org/license/mit/) © [Sebastian Landwehr](https://sebastianlandwehr.com)\n\u003c!-- /LICENSE --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdword-design%2Fjest-image-matcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdword-design%2Fjest-image-matcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdword-design%2Fjest-image-matcher/lists"}