Skip to content

Files

Latest commit

7795c7b · Jul 3, 2022

History

History

exercise1-jest

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 3, 2022
May 12, 2022

Accessibility Unit Testing with Jest

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.

Exercise: Write unit tests for the IconButton component

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: