Let's talk about more tests, like, one test to find them. So, what, how can we use end-to-end testing to help us with the accessibility. So, there is a lib called Jest-Axi. So, we can, like, extend. For this example, I'm using Vitest, but we can use, like, Jest or whatever you want. But I'm just, like, extending the expected to have this specific method, just, like, to have no violations. So, if you think about the input components that I've shown you, we can make, like, a simple test that only renders the components. And we are expecting the results to have no violations. And when we are talking about violations, we are talking about accessibility rules, like well-known accessibility rules. So, this is not adding more effort. Just, like, a simple test we can use and we can write to avoid us to having this kind of accessibility issue.
But there is more. So, one test to bring them all. So, what we are talking about now is accessibility, right? And end-to-end testing. So, we can use something like Cypress to help us to identify this kind of issue as well. So, if you pay attention on the code that I'm sharing, I'm just, like, configuring a test. So, before each, I'm just doing, like, a simple line that is CI dot inject x. So, we have this library available to be used during, like, our tests. And what we can do, we can just, like, run whatever we need. So, in this case, it should not have violations. So, we are still talking about accessibility violations. But in this case, we're focusing on form elements. So, we are just, like, getting an input, getting the focus on the input. And then check the accessibility. And then, like, changing the focus to another input and checking again. So, this will help us, like, to ensure that we didn't, like, break or add a specific accessibility issue. Right? And, of course, CI-driven tests.
So, the pipeline to bind them. So, what I did bring here just, like, a lighthouse GitHub action. So, it's easy, like, to set up.
Comments