Summary
Tests act like a safety harness in our learning; we can build little blocks of understanding, building on top of each other, up and up to ever-greater heights, without fear of falling.
In this chapter, you’ve learned a lot about the TDD experience.
To begin with, you set up a React project from scratch, pulling in only the dependencies you need to get things running. You’ve written two tests using Jest’s describe
, it
, and beforeEach
functions. You discovered the act
helper, which ensures all React rendering has been completed before your test expectations execute.
You’ve also seen plenty of testing ideas. Most importantly, you’ve practiced TDD’s red-green-refactor cycle. You’ve also used triangulation and you learned about the Arrange, Act, Assert pattern.
And we threw in a couple of design principles for good measure: DRY and YAGNI.
While this is a great start, the journey has only just begun. In the following chapter, we’ll test drive a more complex component.