Files
cypress/npm/react/examples/snapshots
Alejandro Estrada 5d52758d82 feat: validate specPattern root level (#19980)
* feat: validate specPattern root level

* Fix/add tests

* Fix test

* Update specExcludePattern

* Fix tests

* Fix/add tests

* Fix/add tests

* Fix tests

* Rename specExcludePattern to excludeSpecPattern

* Fix tests
2022-02-04 10:48:10 -05:00
..

example: react-snapshots

Component testing with snapshots using cypress-plugin-snapshots

Example component taken from Snapshot Testing React Components with Jest

Snapshot test

See cypress/component/PositiveCounter-spec.js and saved snapshots in cypress/component/snapshots/.

Usage

  1. Make sure the root project has been built .
# in the root of the project
npm install
npm run build
  1. Run npm install in this folder to symlink the @cypress/react dependency.
# in this folder
npm install
  1. Start Cypress
npm run cy:open
# or just run headless tests
npm test

Failing tests

If the snapshot contents does not match the saved snapshot file, the test fails. You can click on the snapshot command, review the difference, and if the difference is expected, update the snapshot from the Test Runner's GUI.

Update snapshot

More info

You can use other snapshot plugins from the plugins list