cy-ct-cra-storybook
cy-ct-cra-storybook copied to clipboard
Creat React App + StoryBook + Cypress Component Testing
This is an example of how storybook and cypress can work together hand in hand.
Command
yarn cy
opens the cypress component testing environment.
How to setup Storybook with cypress component testing
- Create react app
yarn create create-app <project-name>
- Initialize storybook using
npx -p @storybook/cli sb init
- Create stories in storybook (src/stories/Button.stories.tsx)
- Add cypress component testing via
yarn create cypress-tests
- Install the link library
yarn add -D @storybook/testing-react
- Load
.storybook/preview
incypress/support
to install all storybook globals and decorators in cypress (cypress/support/index.js) - Mount stories in cypress tests (src/stories/Button.test.tsx)
To install cypress
See the cypress directory