This is an example of how storybook and cypress can work together hand in hand.
yarn cy opens the cypress component testing environment.
- 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/previewincypress/supportto install all storybook globals and decorators in cypress (cypress/support/index.js) - Mount stories in cypress tests (src/stories/Button.test.tsx)
See the cypress directory