New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cypress-storybook-commands

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-storybook-commands

Commands to help navigate storybook in Cypress for functional and visual component level testing

  • 0.1.1
  • Source
  • npm
  • Socket score

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

Cypress Storybook Commands

This package registers a set of cypress commands that will allow you to test components in storybook visually and functionally.

Usage

In your cypress/support/commands.js add the following:

import addStoryBookCommands from './commands/storybook';

addStoryBookCommands({
  platform: 'web', // set to native if using storybook-native
  viewportPresets: { // see https://docs.cypress.io/api/commands/viewport.html#Arguments
    mobile: 'iphone-6',
    tablet: 'ipad-2',
    laptop: 'macbook-15',
    desktop: [1920, 1080]
  },
  registerSnapshotCommands: true // set to false if you already include cypress-image-snapshot/command in your setup
})

Note: update platform accordingly for the type of storybook you are using, default is web.

Visual regression tests

In your test file e.g. cypress/tests/components/visual-regression.js you can simply:

context('Components', () => {
  it('render components as expected', () => {
    cy.visit('/')
      .runStorybookVisualRegression();
  });
});

Functional tests

In your test file e.g. cypress/tests/components/accordion.js you can load the story to carry out functional testing as follows:

context('Components: Accordion', () => {
  beforeEach(() => {
    cy.visit('/')
      .loadStory('Accordion.default')
  });

  it('toggles content as expected', () => {
    cy.get('div[data-testid="tab"]').click()
    ... etc ...
  });
});

Note: Accordion.default is the testID set in the navigator for that story via the data-testid attribute.

FAQs

Package last updated on 09 Sep 2019

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