mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-08 16:19:55 -06:00
Co-authored-by: Дмитрий Коваленко <dmitrijkovalenko@Dmitrijs-MacBook-Pro.local> Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
example: react-snapshots
Component testing with snapshots using cypress-plugin-snapshots
Example component taken from Snapshot Testing React Components with Jest
See cypress/component/PositiveCounter-spec.js and saved snapshots in cypress/component/snapshots/.
Usage
- Make sure the root project has been built .
# in the root of the project
npm install
npm run build
- Run
npm installin this folder to symlink the@cypress/reactdependency.
# in this folder
npm install
- 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.
More info
You can use other snapshot plugins from the plugins list

