Storybook allows you to take your Play functions and run through them all and in order to make sure they all do what you expect them to do.
You will need to install their test runner in order to get started with this:
npm install -D @storybook/test-runner
Make sure that you have your Playwright browsers installed by running npx playwright install
.
Storybook must be running in order to run your tests with @storybook/test-runner
.
Once your Storybook is up and running, you can run your tests.
npx test-storybook
Alternatively, you can—and should—add a script to your package.json
to run the tests.
Running Your Tests in Github Actions
We’re not going to cover this in our brief time together today, but the official Storybook documentation has some example Github Actions for running your Storybook tests as part of your CI/CD process.