Okay, and let's talk about adding a level of automation. So, to add the accessibility component testing, automated testing, first let's create a component. So, this is a component, it's a button. We learned from the previous slide that the button has to have the button tag. So, we use the button tag. It has, the thing that interests in here is the primary prop, which said that, is it a primary or secondary button? Now, we select this button and we create two storybooks stories, the primary story and the secondary story. If you're not familiar with storybook, it doesn't really matter. It's a great tool, but it's not the subject of this talk. But go try it, it's really great.
So if you run storybook, we'll get, actually we get two screens that render only the buttons, and it looks like this. It has the primary button, it looks like this, and the secondary button that looks like that. A bit different colors. Now, we will use this as a basis for our tests. In storybook, there is a magic button, I put a bunch of arrows so we won't miss it. If you click it, it opens the component in a separate tab, actually without all the wrapping of storybook UI. So, it will open without the toolbars, and it will isolate only the component we want in a specific state with specific props. We will use that as a base for our functional and accessibility testing.
So, this is our functional test. We will use Cypress for it, and the test is pretty simple. We see two tests which are identical, first for primary button, and second for the secondary button. They visit the URL that storybook created. We click on the button, and we assert that the click is registered. And if we wanna run it with Cypress, we see that everything works, and it's great, it's green again. Okay, now let's add accessibility to the mix. So, what should we expect from an accessibility framework to find? Some of the things that we wanted to tell us is that there is a missing alternative text on an image, or we have a button, but it's not focusable by keyboard, or we have a pop-up, but the pop-up is not accessible, or we have text in some color and with some background color, but the color contrast is insufficient, so it's hard to see for people with low visibility. All of the things and more are the things that we are working on in Events. These are kind of the things that we are detecting using our engines. So, because we work in Events, we want to use our own tools, so we use our own tools also for test automation. And we do it by providing an SDK for Cypress that gives us the ability to gather accessibility issues. So, if we call evstart, this is the command, it says, Events, please start gathering accessibility issues and then we do some things and we call evstop and then it gathers all of these issues and we can run our validations against these issues, run the expect or assertions in our test.
Comments