Understanding TDD
TDD isn’t exactly a new kid on the block. Originating from Extreme Programming (XP), a software development methodology that encourages frequent releases in short cycles, TDD has roots going back to the late 1990s. It was Kent Beck, one of the original signatories of the Agile Manifesto, who popularized this practice as a core part of XP. The practice has since grown beyond the realm of XP and is now commonly utilized in various methodologies and frameworks, React included.
At the heart of TDD is a very simple, yet profoundly effective cycle known as the Red-Green-Refactor loop:
As you can see, there are essentially three steps when practicing TDD:
- Red: At this stage, you write a test that defines a function or improvements of a function. This test should initially fail because the function isn’t implemented yet. In most test frameworks (for example, Jest), there will be some...