{"name":"cypress-image-snapshot","version":"1.0.2","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","files":["*.js"],"scripts":{"prebuild":"rimraf *.js","build":"babel src --out-dir .","test":"jest","prepublish":"npm run build","precommit":"lint-staged"},"dependencies":{"jest-image-snapshot":"2.4.3","lodash.kebabcase":"^4.1.1"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-preset-env":"^1.7.0","husky":"^0.14.3","jest":"^23.2.0","lint-staged":"^7.2.0","prettier":"^1.13.6","rimraf":"^2.6.2"},"peerDependencies":{"cypress":"^3.0.2"},"lint-staged":{"linters":{"**/*.{js,json,md}":["prettier --write","git add"]},"ignore":["*.js"]},"prettier":{"printWidth":80,"semi":true,"singleQuote":true,"trailingComma":"es5"},"babel":{"presets":[["env",{"targets":{"node":"6.10"}}]],"plugins":["transform-object-rest-spread"]},"jest":{"testPathIgnorePatterns":["<rootDir>/examples/","<rootDir>/node_modules/"]},"gitHead":"69f3815631fd2dbc34758601cf3328a89ea87707","bugs":{"url":"https://github.com/palmerhq/cypress-image-snapshot/issues"},"homepage":"https://github.com/palmerhq/cypress-image-snapshot#readme","_id":"cypress-image-snapshot@1.0.2","_npmVersion":"6.2.0","_nodeVersion":"8.11.3","_npmUser":{"name":"jayjaycross","email":"jackjocross@gmail.com"},"dist":{"integrity":"sha512-NwzA9+KsoL6DdQooS2XQwBUZv1453yiEtnR2JQLrcH9LxE1y1B2ZYdBd2FcR4/S4ghiTd9iKUa48KdqsMqfslQ==","shasum":"2c6355f52575e787176886a63bc644ed6c5c4e78","tarball":"http://registry-npm.ywwl.com/cypress-image-snapshot/download/cypress-image-snapshot-1.0.2.tgz","fileCount":5,"unpackedSize":14476,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbTmEtCRA9TVsSAnZWagAASXcP/Rik2G/JE7GvhXMon1U9\n8qyowwJw/1Tr3wCyRlT1Sr4vjWC9pdys4UPc5b6wjyz7ZRZ2jXoWAwiWShnK\nX5F7oQQfs8WZjkx570yj8nytWJ1JFCgA0n7hsP7zM/8//Q4Up+eHyUd3jM/G\naLahSsk5ZbePK69b/J4gWS6yfR2d35DtaspVeXS30KDOgtxGuKR0JFB3G0O1\nv2Y9b+M2Ke2fy+0OZfeJUgiG2JdPZO/jjDwJoI/ElvpkmHk6OBHJV99TxMXD\n8f/IE7QgGpPwW2iivOgNDIJOVMue4Vcpv6BFxDaCHGLjBJxeqGC4DsFkPN11\ncEoyizrQtrwL1dukWW+PZ1yqGMU+AdQGR3FEg//vrGt5rUiRFSzmXO97rRMB\nw5E5DMB1liugLb8AYMF9R4fsSo0q6SWDFF9BTPaR2hkyPAgmjP7Iajuc/eDd\nKbu8wPhyS7Xs4SrVE1gS1E7ErU13PC7RvuTfocQmRhIRHp3k9wzN/1Ka2KVh\njJX5tN86YV6rz84udmMd/fKhvMCGk79n2KmyLIFHoHrgbVyWgearvOgAvM2O\nF4M8ULQ6L3fE76WBD65AWAtSMu8OIjVwyAfL2j0A+zR5OWFB83Fej2oIfTXQ\nH3O2C3ZXCu+stWi8zKHXhqW9bConQb6f8dS9sSUiWQvtTCHSFN8ABuMehjYP\n83ic\r\n=H7wx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAIuN2c7NMkNY3MT1alW16qx15oHYXmNcatTFJBqAU1YAiEAtwGMfHpvY7+DI/1yCx2Ct/og3/mSFza9hTQnm7CNxE0="}],"size":4532,"noattachment":false,"key":"/cypress-image-snapshot/-/cypress-image-snapshot-1.0.2.tgz"},"maintainers":[{"name":"jayjaycross","email":"jackjocross@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cypress-image-snapshot_1.0.2_1531863341483_0.08345167862854397"},"_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":1531863341570,"_cnpm_publish_time":1531863341570,"dist-tags":{"latest":"4.0.1","next":"2.0.0-1"}}