Jasmine JavaScript Testing

If you want to take your JavaScript coding to a new level of reliability and proficiency, this book is for you. Discover how to use Jasmine for unit testing whilst learning best practice for the whole JavaScript universe.
Preview in Mapt

Jasmine JavaScript Testing

Paulo Ragonha

If you want to take your JavaScript coding to a new level of reliability and proficiency, this book is for you. Discover how to use Jasmine for unit testing whilst learning best practice for the whole JavaScript universe.
Mapt Subscription
FREE
$29.99/m after trial
eBook
$14.00
RRP $19.99
Save 29%
Print + eBook
$33.99
RRP $33.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$14.00
$33.99
$29.99p/m after trial
RRP $19.99
RRP $33.99
Subscription
eBook
Print + eBook
Start 30 Day Trial

Frequently bought together


Jasmine JavaScript Testing Book Cover
Jasmine JavaScript Testing
$ 19.99
$ 14.00
Jasmine JavaScript Testing - Second Edition Book Cover
Jasmine JavaScript Testing - Second Edition
$ 27.99
$ 19.60
Buy 2 for $31.50
Save $16.48
Add to Cart
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 

Book Details

ISBN 139781782167204
Paperback146 pages

Book Description

From a little renegade scripting language to the de facto standard platform of today, JavaScript has become a universal language available in the widest range of devices; it is truly the 'write once, run everywhere’ language. However, as JavaScript applications become more complicated, testing and applying sustainable software engineering practices also become mandatory.

Jasmine JavaScript Testing is a practical guide to a more sustainable JavaScript development process. You will learn by example how to drive the development of a web application using tests and best practices.

This book is about becoming a better JavaScript developer. So, throughout the chapters, you will not only learn about writing tests, but also about the best practices for writing software in the JavaScript language. This book is about acknowledging JavaScript as a real platform for application development and leveraging all of its potential. You will also learn about tooling and automation and how to make your life easier and more productive.

You will learn how to create a sustainable codebase with the help of Jasmine. We will take a look at integrated testing (with a backend NodeJS server) and how you can speed this process up by faking AJAX requests. As you progress through the book, you will learn about the challenges of testing an application built on top of a framework and how you can prevent your application from suffering from dependency management hell. Also, since your applications need to get into production, you will learn about optimizing the code to reduce the number of requests the browser needs to make while loading your application.

With this book, you will learn everything you need to know to become a real professional in the ever-demanding JavaScript universe.

Table of Contents

Chapter 1: Getting Started with Jasmine
JavaScript – the bad parts
Jasmine and Behavior-Driven Development
Downloading and first run
Summary
Chapter 2: Your First Spec
The Investment Tracker application
Jasmine basics and thinking in BDD
Setup and teardown
Nested describes
Understanding matchers
Summary
Chapter 3: Testing Frontend Code
Thinking in terms of components (Views)
The module pattern
Using HTML fixtures
Basic View coding rules
Testing Views with jQuery matchers
Summary
Chapter 4: Asynchronous Testing – AJAX
Setting up the Scenario
Writing the spec
Summary
Chapter 5: Jasmine Spies
The "bare" Spy
Spy an object's functions
Testing DOM events
Summary
Chapter 6: Light Speed Unit Testing
Jasmine Stubs
Sinon.JS
Summary
Chapter 7: Testing Backbone.js Applications
The Backbone model
Testing Backbone collections
Testing Backbone Views
Testing Backbone routers
Summary
Chapter 8: Build Automation
RequireJS
Headless testing with PhantomJS
Grunt
Managing NPM dependencies
Summary
Chapter 9: Conclusion

What You Will Learn

  • Drive your application development entirely by tests
  • Organize your application code in modules with RequireJS
  • Create a fully-tested jQuery plugin
  • Solve problems and learn best practices for asynchronous testing
  • Use Stubs and Spies to perform quick unit testing
  • Test-drive a BackboneJS application
  • Optimize your JavaScript code to production
  • Master the power of tooling and automation with GruntJS
  • Run your tests on the cloud with Travis-CI

Authors

Table of Contents

Chapter 1: Getting Started with Jasmine
JavaScript – the bad parts
Jasmine and Behavior-Driven Development
Downloading and first run
Summary
Chapter 2: Your First Spec
The Investment Tracker application
Jasmine basics and thinking in BDD
Setup and teardown
Nested describes
Understanding matchers
Summary
Chapter 3: Testing Frontend Code
Thinking in terms of components (Views)
The module pattern
Using HTML fixtures
Basic View coding rules
Testing Views with jQuery matchers
Summary
Chapter 4: Asynchronous Testing – AJAX
Setting up the Scenario
Writing the spec
Summary
Chapter 5: Jasmine Spies
The "bare" Spy
Spy an object's functions
Testing DOM events
Summary
Chapter 6: Light Speed Unit Testing
Jasmine Stubs
Sinon.JS
Summary
Chapter 7: Testing Backbone.js Applications
The Backbone model
Testing Backbone collections
Testing Backbone Views
Testing Backbone routers
Summary
Chapter 8: Build Automation
RequireJS
Headless testing with PhantomJS
Grunt
Managing NPM dependencies
Summary
Chapter 9: Conclusion

Book Details

ISBN 139781782167204
Paperback146 pages
Read More

Read More Reviews

Recommended for You

Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Responsive Web Design with HTML5 and CSS3 Book Cover
Responsive Web Design with HTML5 and CSS3
$ 23.99
$ 4.80
Object-Oriented JavaScript - Second Edition Book Cover
Object-Oriented JavaScript - Second Edition
$ 29.99
$ 21.00
AngularJS Directives Book Cover
AngularJS Directives
$ 19.99
$ 2.00
Software Testing using Visual Studio 2010 Book Cover
Software Testing using Visual Studio 2010
$ 26.99
$ 18.90
AngularJS Web Application Development Blueprints Book Cover
AngularJS Web Application Development Blueprints
$ 29.99
$ 21.00