Learn TDD With Mocha
Lesson 1 of 1
  1. 1
    Test-driven development (TDD) is a programming technique where you write test code before implementation code. Test code is written to define the desired behavior of your program. The test output …
  2. 2
    When we use the red, green, refactor cycle, we: 1. Write test code that fails 2. Write implementation code to make the test pass 3. Consider refactoring the code As you learn TDD, it may feel back…
  3. 3
    #### Congrats you’re in the red! The red error messages describe the failures of our implementation code, so we can specifically address each issue that is preventing our test from passing. Let’…
  4. 4
    #### Congrats you’re in the green! Once all your tests pass, you can confidently refactor your code — restructure and improve it without changing its external behavior. The confidence come…
  5. 5
    Congratulations, you have made it through your first red-green-refactor cycle using TDD! The next step is to repeat this cycle to build a more complete implementation of the .initials method. Once…
  6. 6
    Now that we have tests that cover more than one condition, it is time to program the actual behavior that we want our .initials method to execute. Let’s think about the current state of Phrase.ini…
  7. 7
    Congrats, you’re back in the green! Which means the next step is to refactor the code so that your tests are fast, complete, reliable, isolated, maintainable, and expressive. Also, you want to mak…
  8. 8
    Now that we have written and refactored a few tests, it’s time to consider edge cases. An edge case is a problem or situation that occurs only at an extreme (maximum or minimum) operating param…
  9. 9
    We have just covered Test Driven Development with Mocha. At a high-level the process is: - Write The Test — Start with a test describing the functionality we’d like to see. - Fail …

What you'll create

Portfolio projects that showcase your new skills

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory