August 04, 2021
(Updated: September 27, 2021)
How do you know if the system you built works? Through testing it! But testing different aspects of your system manually (i.e. by entering text into input fields and clicking buttons yourself) can be tedious, and take up a lot of time. This is why developers rely on tools which run through a defined list of expectations to fulfill and alert the developer if one (or many) outcomes did not turn out as expected.
Unit testing is where individual parts of an application (each 'unit') are tested in isolation from one another. So, for example, in a standard calculator app, you would test the
add function first to see if numbers add together and produce an expected result, and then the
subtract function to see if numbers subtract from each other and produce an expected result, and then the
multiply function, etc.
Testing FrameworkDeveloped and maintained by Facebook and contributors. Pretty much the go to for React and can be used alongside React Testing Library.
A great introduction on how to use Kent C Dodd's (who I am a big fan of) testing framework. Everyone should learn at least one thing from this article.
End to end testing is where the relationship between multiple parts of an application are tested. It simulates how the user would use the application, wherein multiple components are involved and rely on one another. As a simple example, when the user clicks on the "hamburger button" (component one), does the correct menu (component two) appear? For a more complex example, when the user submits data through a form (component one), is that data submitted to the database (component two) correctly?
Easily Write Tests
Cypress io is an open source end to end testing framework for testing anything that runs in the browser. Follow the whole user journey and easily pick up on any issues a long the way.
Do you know a resource that could benefit another reader and is relevent for this page? Let me know by leaving a short message below and I will take a look!