An Introduction to Testing
Learn the types of testing in detail with the use of Jest and Cypress as test runners.
We'll cover the following
Testing basics
Testing is an essential part of any development workflow and can be divided into three separate testing phases:
Unit testing: These tests aim to make sure that every single function in our code is working. They do that by testing the code base’s functions individually against correct and incorrect inputs, asserting their results and possible errors to ensure they’re working as expected.
Integration testing: In this case, we want to ensure that separate parts of our application, such as functions and modules, are cohesively working together. For instance, we want to assert that composing two functions results in a certain output, and so on. Unlike unit tests, where we test our functions individually, with integration tests, we ensure that a whole group of aggregated functions and modules are producing a correct output when given a different set of input.
End-to-end testing: This testing strategy reproduces a typical user interaction with our application, ensuring that the app responds with a specific output once a given action occurs, just like we would do by testing the website manually on a web browser. For instance, if we build a form, we want to automatically guarantee that it’s working correctly, validating the input, and performing a specific action on the form’s submission. Also, we want to test that the user interface is rendering as we intended by using particular CSS classes, mounting certain HTML elements, and so on.
Get hands-on with 1200+ tech skills courses.