Book Image

Jasmine Cookbook

By : Munish Kumar
Book Image

Jasmine Cookbook

By: Munish Kumar

Overview of this book

Table of Contents (16 chapters)
Jasmine Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Introduction


Behavior-Driven Development (BDD) is a software development process based on Test-Driven Development (TDD). Before we start writing Jasmine tests using TDD and BDD, let's get a briefing of how both processes work and how they play a pivotal role in software development.

TDD is a unit testing based test-first or fail-first approach where we write the test before writing the code. Thereafter, we write the minimum amount of code just to pass the test. Finally, we refactor the code to acceptable standards. This form of approach focuses on the specification of the application, thus decreasing the probability of bugs. In other words, we can say that TDD is a defect-prevention approach that focuses on internal (code) quality.

A JavaScript application can be developed using TDD by performing the following steps:

  1. Write a failing unit test.

  2. Make the test pass.

  3. Refactor the test.

  4. Repeat the steps.

  5. When you cannot think of any more tests or there is no more scope for refactoring, you should...