Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Jasmine Cookbook

You're reading from   Jasmine Cookbook Over 35 recipes to design and develop Jasmine tests to produce world-class JavaScript applications

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784397166
Length 276 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Munish Kumar Munish Kumar
Author Profile Icon Munish Kumar
Munish Kumar
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Jasmine Framework 2. Jasmine with TDD and BDD Processes FREE CHAPTER 3. Customizing Matchers and Jasmine Functions 4. Designing Specs from Requirement 5. Jasmine Spies 6. Jasmine with AJAX, jQuery, and Fixtures 7. Code Coverage with Jasmine Tests 8. Jasmine with Other Tools 9. Developing JavaScript Apps Using Jasmine – a Real-time Scenario Index

Implementing Jasmine tests with a Data-Driven approach


In the Data-Driven approach, Jasmine specs get input or expected values from the external data files (JSON, CSV, or TXT files, and so on) that are required to run the tests. In other words, we isolate test data and Jasmine specs so that we can prepare the test data (input or expected values) separately as per the need of the specs or scenarios. You can see the Data-Driven approach in the following diagram:

In this recipe, we will learn how to implement Jasmine specs for the scenarios described in the previous recipe, using the Data-Driven approach. For more details, refer to the previous recipe, Implementing Jasmine specs with Web/HTML.

How to do it...

You need to perform the following steps to implement Jasmine tests with the Data-Driven approach:

  1. First, you need to create a US_TaxEstimation_DataDriven_spec.js spec file under the /spec folder and get the following code from the US_Tax_Estimation_spec.js spec file created in the previous...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image