Jasmine Cookbook

Over 35 recipes to design and develop Jasmine tests to produce world-class JavaScript applications

Jasmine Cookbook

This ebook is included in a Mapt subscription
Munish Sethi

Over 35 recipes to design and develop Jasmine tests to produce world-class JavaScript applications
$10.00
$49.99
RRP $39.99
RRP $49.99
eBook
Print + eBook
Access every Packt eBook & Video for just $100
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Find Out More
 
Preview in Mapt

Book Details

ISBN 139781784397166
Paperback276 pages

Book Description

Jasmine provides a rich set of libraries to design and develop tests for JavaScript applications. Its tests aim to run on any JavaScript-enabled platform and have easy-to-read syntax.

This book is a comprehensive guide to designing and developing Jasmine tests to produce world-class software. The recipes are elaborated using examples from a real-world application, which involves various aspects of designing and developing tests from simple to complex level. You will learn how to create tests for jQuery and Ajax, HTML and JSON fixtures, CoffeeScript, and AngularJS. By learning and applying the best practices throughout this book, you can deliver your applications with zero defects and ensure success for you and your clients.

Table of Contents

Chapter 1: Getting Started with Jasmine Framework
Introduction
Writing your first Jasmine test
Adding specs to your Jasmine test
Adding expectations and matchers to the test
Applying different matchers to the Jasmine test
Applying setup and teardown functions to the Jasmine test
Using the "this" keyword
Chapter 2: Jasmine with TDD and BDD Processes
Introduction
Writing Jasmine tests using TDD and BDD processes
Creating a Jasmine test for new code using TDD and BDD
Designing Jasmine tests for existing code using TDD and BDD
Defining nested suites to write more meaningful specs
Chapter 3: Customizing Matchers and Jasmine Functions
Introduction
Writing a Jasmine test using a custom equality tester function
Writing Jasmine tests with custom matchers
Writing Jasmine tests for exceptions
Declaring pending specs with Jasmine tests
Chapter 4: Designing Specs from Requirement
Introduction
Writing useful specs by analyzing the test requirements
Implementing the Jasmine test corresponding to the specs
Applying Acceptance Criteria to the Jasmine test
Organizing Jasmine specs into groups and subgroups
Chapter 5: Jasmine Spies
Introduction
Writing Jasmine tests using the spyOn() method and special matchers for spies
Writing Jasmine tests using tracking properties
Writing Jasmine tests with your own custom spy method
Using jasmine.any and jasmine.objectContaining
Writing Jasmine tests to mock the JavaScript timeout functions
Chapter 6: Jasmine with AJAX, jQuery, and Fixtures
Introduction
Writing Jasmine specs for AJAX
Designing Jasmine specs with HTML and JSON fixtures
Writing Jasmine specs for jQuery
Writing Jasmine specs using custom jQuery matchers
Writing Jasmine specs for asynchronous operations using the done() function
Chapter 7: Code Coverage with Jasmine Tests
Introduction
Configuring code coverage tools
Generating code coverage using karma and istanbul
Writing Jasmine specs for uncovered branches/code
Increasing code coverage for existing code
Chapter 8: Jasmine with Other Tools
Introduction
Writing Jasmine tests for AngularJS
Using Jasmine with CoffeeScript
Writing Jasmine tests for Node.js
Chapter 9: Developing JavaScript Apps Using Jasmine – a Real-time Scenario
Introduction
Defining Jasmine specs corresponding to a user story
Implementing Jasmine specs with Web/HTML
Implementing Jasmine tests with a Data-Driven approach
Creating Jasmine tests for a change request

What You Will Learn

  • Develop JavaScript applications with Jasmine using the behavior-driven development (BDD) process
  • Apply custom matchers by enhancing your Jasmine tests to test specific features or functionality
  • Design Jasmine specs for jQuery and Ajax with HTML and JSON fixtures
  • Generate code coverage analysis for JavaScript code using Karma and Istanbul
  • Create Jasmine tests for CoffeeScript and AngularJS
  • Implement E2E (end-to-end) Jasmine specs for JavaScript applications to simulate a real-time scenario

Authors

Table of Contents

Chapter 1: Getting Started with Jasmine Framework
Introduction
Writing your first Jasmine test
Adding specs to your Jasmine test
Adding expectations and matchers to the test
Applying different matchers to the Jasmine test
Applying setup and teardown functions to the Jasmine test
Using the "this" keyword
Chapter 2: Jasmine with TDD and BDD Processes
Introduction
Writing Jasmine tests using TDD and BDD processes
Creating a Jasmine test for new code using TDD and BDD
Designing Jasmine tests for existing code using TDD and BDD
Defining nested suites to write more meaningful specs
Chapter 3: Customizing Matchers and Jasmine Functions
Introduction
Writing a Jasmine test using a custom equality tester function
Writing Jasmine tests with custom matchers
Writing Jasmine tests for exceptions
Declaring pending specs with Jasmine tests
Chapter 4: Designing Specs from Requirement
Introduction
Writing useful specs by analyzing the test requirements
Implementing the Jasmine test corresponding to the specs
Applying Acceptance Criteria to the Jasmine test
Organizing Jasmine specs into groups and subgroups
Chapter 5: Jasmine Spies
Introduction
Writing Jasmine tests using the spyOn() method and special matchers for spies
Writing Jasmine tests using tracking properties
Writing Jasmine tests with your own custom spy method
Using jasmine.any and jasmine.objectContaining
Writing Jasmine tests to mock the JavaScript timeout functions
Chapter 6: Jasmine with AJAX, jQuery, and Fixtures
Introduction
Writing Jasmine specs for AJAX
Designing Jasmine specs with HTML and JSON fixtures
Writing Jasmine specs for jQuery
Writing Jasmine specs using custom jQuery matchers
Writing Jasmine specs for asynchronous operations using the done() function
Chapter 7: Code Coverage with Jasmine Tests
Introduction
Configuring code coverage tools
Generating code coverage using karma and istanbul
Writing Jasmine specs for uncovered branches/code
Increasing code coverage for existing code
Chapter 8: Jasmine with Other Tools
Introduction
Writing Jasmine tests for AngularJS
Using Jasmine with CoffeeScript
Writing Jasmine tests for Node.js
Chapter 9: Developing JavaScript Apps Using Jasmine – a Real-time Scenario
Introduction
Defining Jasmine specs corresponding to a user story
Implementing Jasmine specs with Web/HTML
Implementing Jasmine tests with a Data-Driven approach
Creating Jasmine tests for a change request

Book Details

ISBN 139781784397166
Paperback276 pages
Read More

Read More Reviews