From the course: Building UI Components with Storybook: Master React Components and UI Design with Storybook for Better Efficiency

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Testing interactions and events with React components in Storybook

Testing interactions and events with React components in Storybook

The final part of our journey into building this storybook intro application example together is to take a look at testing, testing components, and what storybook offers us for testing our actions for creating tests. All right, so I want you to import back in our counterstories.jsx, please, because I'm polite, two different functions we've got within and user events. So user events in which we can assign different types of methods, in this case the click and within in which we can set up basically our get elements. In this case we can bring in our canvas element and we can get the button, target the button, and then set up these synthetic events and see how they respond and display them as stories. So how does it work? Well, with withinInUserEvent, we want to grab that, of course, from Storybook. So we want to make sure that we're getting that from Storybook. And we're getting that from the testing library. All right. And now that we have those, we want to make a new story at the…

Contents