TDD Style Long Practice: Test-Driven Development

Now it is time to start writing some tests! For this next practice, you'll be using test-driven development (TDD). A TDD approach dictates that you'll follow the TDD workflow, meaning that you'll need to follow the TDD workflow of Red, Green, Refactor.

Background and Context

tdd-cycle

The three steps for approaching all of the below problems will be to:

  1. Red: Write the tests and watch them fail (a failing test is red).
  2. Green: Write the minimum amount of code to ensure the test passes.
  3. Refactor: Refactor the code you just wrote to make it readable and maintainable.

You can assume for the rest of the practice that you will be using Mocha as your testing framework and Chai as your assertion library.

Be sure to utilize the available documentation for this practice:

The tests you are writing today will be good practice for the rest of your programming career so take your time and ensure you are writing the best tests you can!

Phase 0: Set up

Clone the starter from the Download link at the bottom of this page.

Run npm install to install any dependencies.

Follow the directions to complete each phase:

  • Phase 1: Testing the reverseString function
  • Phase 2: Testing multiple functions
  • Phase 3: Testing the myMap function
  • Phase 4: Testing a class
  • Phase 5: Testing multiple classes