Creating a Jasmine test for new code using TDD and BDD

Writing Jasmine tests for new code is straightforward compared to writing Jasmine tests for existing code. In this recipe, we will learn how to design specs and write tests for new code.

To write a Jasmine test for new code using TDD and BDD, let's assume that you are working with a bank in a credit card division. There are different business rules that exist to accept credit card numbers.

"As a credit card administrator, I want to validate credit card numbers so that I can check their authenticity for further processing."

Let's consider a scenario in the following context that a credit card number should be valid to shop in online store:

Scenario-1: The credit card number should have 16 digits ...

Get Jasmine Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.