{"name":"cypress-image-snapshot","version":"4.0.1","description":"Cypress bindings for jest-image-snapshot.","repository":{"type":"git","url":"git+https://github.com/palmerhq/cypress-image-snapshot.git"},"author":{"name":"Jack Cross","email":"jack@palmer.net"},"license":"MIT","engines":{"node":">=8"},"scripts":{"prebuild":"rimraf *.js","build":"babel src --out-dir .","test":"jest","lint":"eslint src","prepublish":"npm run build","changeset":"changeset","release":"changeset publish"},"dependencies":{"chalk":"^2.4.1","fs-extra":"^7.0.1","glob":"^7.1.3","jest-image-snapshot":"4.2.0","pkg-dir":"^3.0.0","term-img":"^4.0.0"},"devDependencies":{"@changesets/changelog-github":"^0.2.8","@changesets/cli":"^2.13.1","babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.7.0","eslint":"^5.10.0","eslint-config-airbnb-base":"^13.1.0","eslint-config-prettier":"^3.3.0","eslint-plugin-cypress":"^2.1.3","eslint-plugin-import":"^2.14.0","husky":"^1.2.1","jest":"^23.6.0","prettier":"1.15.3","pretty-quick":"^1.8.0","rimraf":"^2.6.2"},"peerDependencies":{"cypress":"^4.5.0"},"husky":{"hooks":{"pre-commit":"pretty-quick --staged"}},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"eslintConfig":{"extends":["airbnb-base","prettier"],"plugins":["cypress"],"env":{"cypress/globals":true}},"babel":{"presets":[["env",{"targets":{"node":"8.0"}}]],"plugins":["transform-object-rest-spread"]},"jest":{"testPathIgnorePatterns":["<rootDir>/examples/","<rootDir>/node_modules/"]},"gitHead":"0510252bc5f192c410bcca45b511f07737bce4a2","bugs":{"url":"https://github.com/palmerhq/cypress-image-snapshot/issues"},"homepage":"https://github.com/palmerhq/cypress-image-snapshot#readme","_id":"cypress-image-snapshot@4.0.1","_nodeVersion":"12.20.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-PBpnhX/XItlx3/DAk5ozsXQHUi72exybBNH5Mpqj1DVmjq+S5Jd9WE5CRa4q5q0zuMZb2V2VpXHth6MjFpgj9Q==","shasum":"59084e713a8d03500c8e053ad7a76f3f18609648","tarball":"http://registry-npm.ywwl.com/cypress-image-snapshot/download/cypress-image-snapshot-4.0.1.tgz","fileCount":8,"unpackedSize":21911,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgCv5RCRA9TVsSAnZWagAAzt8QAIb31yUoeOQfkvGZ1FfH\nP30hKYRrPSSBcLHJNtL9LrPwxaN2j3eA/8uBSRyqSJLop/WhCoKZ5MI3PvUO\nFCs5HKOdF8761oPMnS74FeIhQzEsWJqYcQ1/63vb6M1yqOvq7nxBK2L7BNgW\ntsoln5HKQcjeoqstdk70iMfJgwF3WxGjSjQ+xItYMVg0mEFobjW2iPT+zTSF\nfQsQJDrb/rAK3jrfLzgLjcSlpTJo8q1hVhs+RpzJP1GzDc+ZcSXnnw6q3Gzc\nD0sSbdiFpKBtiYn6xY4pUFhDP+xFEqrn7BF1pwCHOBKroX6VcfnklMEHxeNv\n+edoVYfCmrAmE+44AC7A+0oJjAW0PQGZufWfvjRKZYwQU52hplOGJGWDVOuk\ncYbRbw0H/cs49gL4CBlUPCmXGYFde/twyVZ2/oIe9QwQ4qK/YMT//DrK0X+a\nntzbP/ifPbGyoxdJLhoNaWbeTIx6yCcT7jzLe6vazAhv0vorhEwK4xKf/12f\nocaHUPdV61aMp3XBggYkuO4hmGx4XQFGC9E/3TbnSUq7oRYqjAyu5h6TxPCP\n3aLw9raP+fcLfTomRKbIFCgMx8cXlVTrZJbIe9JyYZXEkfIiRcNO3QSm3MCm\nQXwiCCthRoTV6rqij2YtMRoCrWRmcC+Ox94hxmPRHijrJhgVH9d7g6o/Y9Cp\no7ub\r\n=iBLa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQClIIXCT//CkfYdP6xS5B0/5dzSfhlt/MVN13xxUkpp1wIhALslYbFcRGyiGhSGHDrtBSyZsbiT44VSc1auVjbumtcW"}],"size":6813,"noattachment":false,"key":"/cypress-image-snapshot/-/cypress-image-snapshot-4.0.1.tgz"},"_npmUser":{"name":"cypress-image-snapshot","email":"cypress-imagesnapshot@jaredpalmer.com"},"directories":{},"maintainers":[{"name":"jaredpalmer","email":"jared@palmer.net"},{"name":"jayjaycross","email":"jackjocross@gmail.com"},{"name":"cypress-image-snapshot","email":"cypress-imagesnapshot@jaredpalmer.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cypress-image-snapshot_4.0.1_1611333201259_0.6552952993517114"},"_hasShrinkwrap":false,"readme":"# Cypress Image Snapshot\n\n\nCypress Image Snapshot binds [jest-image-snapshot](https://github.com/americanexpress/jest-image-snapshot)'s image diffing logic to [Cypress.io](https://cypress.io) commands. **The goal is to catch visual regressions during integration tests.**\n\n[![Discord](https://img.shields.io/discord/769256827007139912?label=%F0%9F%92%AC%20%20join%20us%20on%20discord&style=plastic)](https://discord.com/invite/RevdZTYMzr)\n\n<details>\n<summary>See it in action!</summary>\n\n### Cypress GUI\n\nWhen using `cypress open`, errors are displayed in the GUI.\n\n<img width=\"500px\" src=\"https://user-images.githubusercontent.com/4060187/41942389-5a6705ae-796d-11e8-8003-fadbf7ccf43d.gif\" alt=\"Cypress Image Snapshot in action\"/>\n\n### Composite Image Diff\n\nWhen an image diff fails, a composite image is constructed.\n\n<img width=\"500px\" src=\"https://user-images.githubusercontent.com/4060187/41942163-72c8c20a-796c-11e8-9149-c295341864d3.png\" alt=\"Cypress Image Snapshot diff\"/>\n\n### Test Reporter\n\nWhen using `cypress run` and `--reporter cypress-image-snapshot/reporter`, diffs are output to your terminal.\n\n<img width=\"500px\" src=\"https://user-images.githubusercontent.com/1153686/48518011-303d4580-e836-11e8-83ed-776acae78f9f.png\" alt=\"Cypress Image Snapshot reporter\"/>\n\n</details>\n\n## Installation\n\nInstall from npm\n\n```bash\nnpm install --save-dev cypress-image-snapshot\n```\n\nthen add the following in your project's `<rootDir>/cypress/plugins/index.js`:\n\n```js\nconst {\n  addMatchImageSnapshotPlugin,\n} = require('cypress-image-snapshot/plugin');\n\nmodule.exports = (on, config) => {\n  addMatchImageSnapshotPlugin(on, config);\n};\n```\n\nand in `<rootDir>/cypress/support/commands.js` add:\n\n```js\nimport { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';\n\naddMatchImageSnapshotCommand();\n```\n\n## Syntax\n\n```js\n// addMatchImageSnapshotPlugin\naddMatchImageSnapshotPlugin(on, config);\n\n// addMatchImageSnapshotCommand\naddMatchImageSnapshotCommand();\naddMatchImageSnapshotCommand(commandName);\naddMatchImageSnapshotCommand(options);\naddMatchImageSnapshotCommand(commandName, options);\n\n// matchImageSnapshot\n.matchImageSnapshot();\n.matchImageSnapshot(name);\n.matchImageSnapshot(options);\n.matchImageSnapshot(name, options);\n\n// ---or---\n\ncy.matchImageSnapshot();\ncy.matchImageSnapshot(name);\ncy.matchImageSnapshot(options);\ncy.matchImageSnapshot(name, options);\n```\n\n## Usage\n\n### In your tests\n\n```js\ndescribe('Login', () => {\n  it('should be publicly accessible', () => {\n    cy.visit('/login');\n\n    // snapshot name will be the test title\n    cy.matchImageSnapshot();\n\n    // snapshot name will be the name passed in\n    cy.matchImageSnapshot('login');\n\n    // options object passed in\n    cy.matchImageSnapshot(options);\n\n    // match element snapshot\n    cy.get('#login').matchImageSnapshot();\n  });\n});\n```\n\n### Updating snapshots\n\nRun Cypress with `--env updateSnapshots=true` in order to update the base image files for all of your tests.\n\n### Preventing failures\n\nRun Cypress with `--env failOnSnapshotDiff=false` in order to prevent test failures when an image diff does not pass.\n\n### Reporter\n\nRun Cypress with `--reporter cypress-image-snapshot/reporter` in order to report snapshot diffs in your test results. This can be helpful to use with `--env failOnSnapshotDiff=false` in order to quickly view all failing snapshots and their diffs.\n\nIf you using [iTerm2](https://www.iterm2.com/version3.html), the reporter will output any image diffs right in your terminal 😎.\n\n#### Multiple reporters\n\nSimilar use case to: https://github.com/cypress-io/cypress-example-docker-circle#spec--xml-reports\n\nIf you want to report snapshot diffs as well as generate XML junit reports, you can use [mocha-multi-reporters](https://github.com/stanleyhlng/mocha-multi-reporters).\n\n```\nnpm install --save-dev mocha mocha-multi-reporters mocha-junit-reporter\n```\n\nYou'll then want to set up a `cypress-reporters.json` which may look a little like this:\n\n```json\n{\n  \"reporterEnabled\": \"spec, mocha-junit-reporter, cypress-image-snapshot/reporter\",\n  \"mochaJunitReporterReporterOptions\": {\n    \"mochaFile\": \"cypress/results/results-[hash].xml\"\n  }\n}\n```\n\nwhere `reporterEnabled` is a comma-separated list of reporters.\n\nYou can then run cypress like this:\n\n`cypress run --reporter mocha-multi-reporters --reporter-options configFile=cypress-reporters.json`\n\nor add the following to your `cypress.json`\n\n```\n{\n  ..., //other options\n  \"reporter\": \"mocha-multi-reporters\",\n  \"reporterOptions\": {\n    \"configFile\": \"cypress-reporters.json\"\n  }\n}\n```\n\n## Options\n\n- `customSnapshotsDir` : Path to the directory that snapshot images will be written to, defaults to `<rootDir>/cypress/snapshots`.\n- `customDiffDir`: Path to the directory that diff images will be written to, defaults to a sibling `__diff_output__` directory alongside each snapshot.\n\nAdditionally, any options for [`cy.screenshot()`](https://docs.cypress.io/api/commands/screenshot.html#Arguments) and [jest-image-snapshot](https://github.com/americanexpress/jest-image-snapshot#optional-configuration) can be passed in the `options` argument to `addMatchImageSnapshotCommand` and `cy.matchImageSnapshot()`. The local options in `cy.matchImageSnapshot()` will overwrite the default options set in `addMatchImageSnapshot`.\n\nFor example, the default options we use in `<rootDir>/cypress/support/commands.js` are:\n\n```js\naddMatchImageSnapshotCommand({\n  failureThreshold: 0.03, // threshold for entire image\n  failureThresholdType: 'percent', // percent of image or number of pixels\n  customDiffConfig: { threshold: 0.1 }, // threshold for each pixel\n  capture: 'viewport', // capture viewport in screenshot\n});\n```\n\n## How it works\n\nWe really enjoy the diffing workflow of jest-image-snapshot and wanted to have a similar workflow when using Cypress. Because of this, under the hood we use some of jest-image-snapshot's internals and simply bind them to Cypress's commands and plugins APIs.\n\nThe workflow of `cy.matchImageSnapshot()` when running Cypress is:\n\n1.  Take a screenshot with `cy.screenshot()` named according to the current test.\n2.  Check if a saved snapshot exists in `<rootDir>/cypress/snapshots` and if so diff against that snapshot.\n3.  If there is a resulting diff, save it to `<rootDir>/cypress/snapshots/__diff_output__`.\n\n## Cypress Version Requirements\n\nCypress's screenshot functionality has changed significantly across `3.x.x` versions. In order to avoid buggy behavior, please use the following version ranges:\n\n- `cypress-image-snapshot@>=1.0.0 <2.0.0` for `cypress@>=3.0.0 <3.0.2`\n- `cypress-image-snapshot@>2.0.0` for `cypress@>3.0.2`.\n","publish_time":1611333201423,"_cnpm_publish_time":1611333201423,"dist-tags":{"latest":"4.0.1","next":"2.0.0-1"}}