This application is a small React JS application primarily developed for the purpose of testing. It leverages the power of Jest, a JavaScript testing framework, and React's @testing-library/user-event library to facilitate comprehensive testing.
In this application, I focus on testing two key components:
This component is responsible for user input and interaction. I thoroughly test it using various Jest functions and techniques, including but not limited to:
getByRole
: To access and interact with elements by their role.jest.fn()
: To create mock functions and track their usage.toHaveBeenCalled
: To ensure that specific functions have been called.toHaveBeenCalledWith
: To check if functions were called with the expected arguments.
The UserList component displays a list of users. I conduct comprehensive testing on this component as well, applying similar Jest testing methods.
This React application serves as a practical example of how to employ Jest and @testing-library/user-event for testing React components. By thoroughly testing UserForm.js and UserList, I ensure the reliability and functionality of these essential parts of the application. This approach helps maintain code quality and provides confidence in the application's behavior.