TDD Test Driven Development

The TDD is write tests before write code, then we write the code to make the test pas.

Test Driven Development is often call “red-green” testing that means that we want the test to fail (red test) before the code is written and then after the code is written we see passing test (green test).

The steps will be:

1.- Create a functional component in react (just empty function)

2.- Write the test

3.- Expect the test to fail (because our function actually is doing nothing)

4.- Write the code

5.- The test pass

The TDD is makes a huge difference in how it feels to write test, so write test is part of the process code and not a “chore” to do at the end.

Is more efficient, re-run the tests “for free” after changes.

By Cristina Rojas.