Free Sample
+ Collection
Code Files

Backbone.js Testing

Ryan Roemer

If you dread the business of testing JavaScript and Backbone.js web applications, this book is your guardian angel. In easy stages and lots of examples it takes you through the whole testing situation, introducing you to best practice and current techniques.
RRP $19.99
RRP $39.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781782165248
Paperback168 pages

About This Book

  • Create comprehensive test infrastructures
  • Understand and utilize modern frontend testing techniques and libraries
  • Use mocks, spies, and fakes to effortlessly test and observe complex Backbone.js application behavior
  • Automate tests to run from the command line, shell, or practically anywhere

Who This Book Is For

If you are a JavaScript developer looking to create and implement test support for your Backbone.js applications, then this book is ideal for you.

Table of Contents

Chapter 1: Setting Up a Test Infrastructure
Designing an application and test repository structure
Getting the test libraries
Setting up and writing our first tests
Running and assessing test results
Chapter 2: Creating a Backbone.js Application Test Plan
A Backbone.js refresher
Selecting a Backbone.js application to test
Test paradigms and methods
Testing concepts, approaches, and planning
Testing individual Backbone.js components
Testing application interactions and events
Dipping our toes in the application testing waters
Running the application tests
Chapter 3: Test Assertions, Specs, and Suites
Choosing a test style that fits
Trying out some different styles
A tour of the Chai assertion library
Getting the application and tests ready to run
Writing Mocha test specifications
Testing and supporting Backbone.js views
Aggregating and running the application tests
Test development tips, tricks, and hints
Chapter 4: Test Spies
Fake it 'til you make it
Getting to know Sinon.JS
Spicing up Chai with the Sinon.JS plugin
Testing Backbone.js components with spies
Chapter 5: Test Stubs and Mocks
Replacing method behaviors with Sinon.JS stubs
Faking and verifying behavior with Sinon.JS mocks
Testing Backbone.js components with stubs and mocks
Finding the rest of the Notes application components
A few more Sinon.JS test helpers
Chapter 6: Automated Web Testing
The world of testing beyond humans and browsers
Automating browser environments
Headless testing with PhantomJS
Parting thoughts, next steps, and future ideas

What You Will Learn

  • Install and set up a test infrastructure for Backbone.js applications
  • Run, examine, and understand Mocha test reports
  • Tour the Chai assertion library API with detailed examples
  • Write test suites and specs with the Mocha test framework
  • Fake application behavior in tests using Sinon.JS mocks, spies, and fake servers

In Detail

Frontend web applications are soaring in popularity and the Backbone.js library is leading this charge with a modular, lightweight approach for organizing JavaScript web applications. At the same time, testing client-side JavaScript and Backbone.js programs remains a difficult and tedious undertaking.

Backbone.js Testing brings sensible practices and current techniques to the challenges of Backbone.js test development. The book introduces fundamental testing concepts, comprehensive test infrastructure design, and practical exercises to easily and systematically test modern JavaScript web applications.

The book progresses from Mocha test suites and Chai assertions to advanced test mocks and stubs with Sinon.JS. The requisite libraries and utilities are introduced with in-depth examples and best practices for integration with your applications. The book guides you through the test planning and implementation processes for your application models, views, routers, and other Backbone.js components.

Backbone.js Testing gives you the tools, examples, and assistance to test your Backbone.js web applications thoroughly, quickly, and with confidence.


Read More