Any sort of full pages or even our entire applications. I like to use Cypress.io. This is an open source end-to-end testing framework. It's really great for browser driven testing and it has excellent accessibility support.
Another bonus is Cypress has this Cypress Acts plugin that I really like. It's pretty similar to Lighthouse and React Acts in that it checks for accessibility errors except it's built right into your testing suite. It kind of keeps all of your validation in one place and it allows for really an easy integration into your CI, CD pipeline.
Using Cypress, let's write a very simple test for that same Slack sign-up form that we just talked about. We want to know that our Slack sign-up component works using only a keyboard. We're going to query for our accessible input. We're going to type in a valid email address, hit Tab to get to the Submit button, and then hit the Enter key in order to submit our email address. Finally, we're going to check that our accessible alert is updated with that success message.
Now, that was really quick, simple, super small, but this tests the entire user flow of our Slack sign-up form when we are successfully submitting an email address to this form. We're able to do this simulating using just a keyboard. That's what we want to be checking for in our end-to-end test, specifically. We want to check how is the user interacting with my app or my website? How can I translate that into a test and validate that that works, and how am I doing that through an accessibility lens?
We can also test that we are alerting of errors in the same way that we did in our integration test, making sure that errors are properly announced to our users. Or we can take it a step further and say, what if I wanted to test my entire navigation flow? What happens when a user is using a single page application? And what is the implications for navigation and accessibility support? For end-to-end test, we're thinking about our users, thinking about the flow of our websites and then our apps, and figuring out how do we want to validate all of these concepts as they're coming together.
And that's it for testing. That was a lot to cover using just the three types of tests that we usually focus on. Our unit tests are going to be for our component APIs and our behaviors. Integration tests are going to be for components that interact with each other or depend on other components, and end-to-end tests are for validating entire user flows. So putting all that together, our tooling helps us prevent accessibility bugs from being introduced while we're writing code, committing to code bases, and shipping to production. They're going to help generate audits and uncover where we can improve our accessibility support. And then in our testing, we covered unit integration and end-to-end tests, when it's appropriate to use each kind, and what to test for when we're working in each sort of category.
Now, that was admittedly a lot to cover in a really short amount of time. And there's still plenty that we haven't uncovered, that are really going to be critical for creating an accessibility development flow that will benefit your projects and your teams. So, if I can leave you with really just one piece of advice that I want you to take away, it's going to be that, admittedly, it can be really overwhelming if this is the first time that you've thought about the accessibility of your projects. And you're taking stock of the work that needs to happen in order to bring it up to standards and create really reliable processes around them. So, it's not expected that you have a fully accessible site or 100% test coverage on day one. I'm urging you to make incremental changes where you can and consistently chisel away at the accessibility errors.
Comments