Book Image

TypeScript Essentials

By : Christopher Nance
Book Image

TypeScript Essentials

By: Christopher Nance

Overview of this book

Table of Contents (15 chapters)

Test-driven development

As our applications grow in both size and complexity, it is more important than ever for us to deliver software with as few bugs as possible. Manual testing is inconsistent and slow, which means we need to adopt a more methodical way of ensuring the quality of our software. This need has brought about the notion of test-driven development. Test-driven development is a development cycle that repeats a small set of steps to ensure each line of code is tested. The steps in the test-driven development life cycle are:

  • Adding a test

  • Running the tests

  • Writing the code

  • Running the tests again

  • Refactoring the code

The first thing we want to do is write a test to verify some functionality. This creates a requirement for the code that we have yet to write. This test will initially fail when writing unit tests for new functionality; this is expected and helps to verify that the test does have a failure state. At this point, we run all of the tests, verifying that preexisting tests...