Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-plugin-snapshots

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-plugin-snapshots

Cypress snapshot functionality for data

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
decreased by-56.09%
Maintainers
1
Weekly downloads
 
Created
Source

cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io.

Installation

npm i cypress-plugin-snapshots -S

Usage

describe('data test', () => {
  it('test data', () => {
    return cy.request('data.json')
      .its('body')
      .toMatchSnapshot();
  });
});

Config Cypress.io

Add this to your cypress.json configuration file:

"ignoreTestFiles": [
  "**/*.snap",
  "**/__snapshot__/*"
]

Plugin

Find your cypress/plugins/index.js file and change it to look like this:

const { initPlugin } = require('cypress-plugin-snapshots/plugin');

module.exports = (on, config) => {
  initPlugin(on, config);
  return config;
};

Command

Find your cypress/support/index.js file and add the following line:

import 'cypress-plugin-snapshots/commands';

Make changes to default configuration

You can customize the configuration in the cypress.json file in the root of your Cypress project.

Add the configuration below to your cypress.json file to make changes to the default values.

"env": {
  "cypress-plugin-snapshot": {
    "autopassNewSnapshots": true, /* when true not existing snapshots are automatically saved & passed */
    "diffLines": 3, /* how many lines to include in the diff screenshot */
    "normalizeJson": true, /* Do you want sort keys in JSON */
    "serverEnabled": true, /* Do you want to enable the save server? */
    "serverHost": "localhost", /* Under which host should the save server run? */
    "serverPort": 2121, /* Under which port should the save server run? */
    "updateSnapshots": false /* Automatically save changed snapshots, can be handy if you want to update a bunch of snapshots */
  }
}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

License

This plugin is released under the MIT license.

Keywords

FAQs

Package last updated on 13 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc