Understanding the importance of testing
In software development, testing can take many forms. The two main ones regarding SPFx are as follows:
- Unit tests: These tests aim to verify that individual units of our code perform as expected when isolated from other components. For example, if we have an argument, A, our function should return true, while another argument, B, should result in false. Similarly, a single button click might trigger sequence A, whereas another button click should trigger sequence B. This is the same reasoning for UI components. Regarding SPFx, unit tests shouldn’t have to rely on any SPFx context (i.e., testable outside of a SharePoint page). For this type of test, we usually use the Jest testing framework as it integrates well with SPFx. We won’t deep dive into the framework itself here as that is outside the scope of this book, but we will cover its usage in SPFx in more detail later.
- Integration tests: Integration tests focus on a...