From the course: Testing in React: Beyond Unit Tests

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

TDD fundamentals

TDD fundamentals

- [Instructor] TDD isn't just a testing strategy, it is a development mindset. At its core, TDD is a three-step loop. Red, which means write a failing test. Green, write the minimal code to make it pass. Refactor, clean up the code while keeping the test green. This is known as the Red-Green-Refactor cycle. The idea is to let your test guide your code design and not the other way around. Practicing TDD in development environment helps you to write more compact and functional code. It helps you prevent over-engineering because you only write what you need to pass the test. It helps you to reduce bugs and regression as your hub grows. It encourages you to think from the user's perspective upfront, and most importantly, it builds confidence because every change is backed by a test. The same way we were able to do integration testing, we'll be using that same knowledge to do TDD. Let's go through a simple TDD cycle. We'll build a counter component that starts at zero, increments when the…

Contents