Jest is a testing workhorse in modern web applications. You can test isolated components for accessibility in Jest, particularly for keyboard behavior and programmatic state. By adding Testing Library into the mix, you can get some solid testing work done and provide a contract for accessibility functionality in components.
To start unit testing with Jest, run this command:
yarn test
To keep Jest running while you’re making changes to components, keep it alive with the watch command:
yarn test --watch
Note: To exit the process on MacOS, type Control + C
in your Terminal.
There’s an inaccessible button on the loose! Fix it with a bit of TDD (Test Driven
Development). For the IconButton
component, write Jest unit tests to assert
it has an accessible name and it can be reached and operated with the keyboard.
You will need to make changes to the component to make it pass, as well.
API commands you can use: