This video is available to students only

Storybook test runner

Let's use the Storybook test runner to automate our tests!

In order to avoid having to manually check every story and their interactions after every change we make, Storybook provides a test runner which turns every story into tests, and executes these tests in a headless browser, powered by Playwright. Let's set it up!

First, stop Storybook if it's running. Then, install the test runner:

The test runner needs Storybook to be running, so let's run it again:

Now all you have to do is run the following command in a separate terminal, while Storybook is running:

The test runner will visit every single story, and for simple stories that don't have interactions, it will smoke test them, checking whether they render correctly. For the ones with interactions, it will execute the play function and check whether the assertions will succeed!

 

This page is a preview of Storybook for React Apps

Start a new discussion. All notification go to the author.