Backbone.js Testing
eBook - ePub

Backbone.js Testing

Ryan Roemer

Partager le livre
  1. 168 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Backbone.js Testing

Ryan Roemer

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Approach

This book is packed with step-by-step tutorials and instructions in recipe format to help you create test infrastructures and gradually advance your Backbone.js application development and testing skills.

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Backbone.js Testing est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Backbone.js Testing par Ryan Roemer en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatik et QualitĂ€tssicherung & PrĂŒfung. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2013
ISBN
9781782165248

Backbone.js Testing


Table of Contents

Backbone.js Testing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Setting Up a Test Infrastructure
Designing an application and test repository structure
Getting the test libraries
Mocha
Chai
Sinon.JS
Setting up and writing our first tests
The test driver page
Adding some tests
Running and assessing test results
The first test report
Test report actions
Test timing and slow tests
Test failures
Summary
2. Creating a Backbone.js Application Test Plan
A Backbone.js refresher
Selecting a Backbone.js application to test
Getting acquainted with the Notes application
The anatomy of the Notes application
Test paradigms and methods
Testing concepts, approaches, and planning
Testing individual Backbone.js components
Models
Collections
Templates
Views
Routers
Utilities
Testing application interactions and events
Partial integrations
Events
Dipping our toes in the application testing waters
Namespace
Note model
Running the application tests
Summary
3. Test Assertions, Specs, and Suites
Choosing a test style that fits
Mocha test interfaces
Chai assertion styles
Trying out some different styles
Mocha and Chai BDD interfaces
Mocha TDD and Chai assert styles
Deciding on the project style
A tour of the Chai assertion library
Chaining objects and assertions
Basic value assertions
Comparing values
Object and array validation
Errors
Getting the application and tests ready to run
The Mocha test runner
Reconfiguring the application for testing
Organizing topics and specifications into test suites
Starting up and winding down tests
Writing Mocha test specifications
Asynchronous behavior in tests
Some Backbone.js collection tests
Testing and supporting Backbone.js views
The Notes application single note view
Creating HTML fixtures for view tests
Walking through the view test suite
Aggregating and running the application tests
Test development tips, tricks, and hints
Isolating and excluding tests
Writing testable application code
Summary
4. Test Spies
Fake it 'til you make it
Getting to know Sinon.JS
Spying on functions with Sinon.JS
Anonymous spies
Spy assertions
Function spies
Object method spies
Playing in the sandbox with Sinon.JS test helpers
Delving into the Sinon.JS spy API
The spy API
The spy call API
Spicing up Chai with the Sinon.JS plugin
Introducing and installing Chai plugins
The Sinon.JS plugin
Testing Backbone.js components with spies
The Notes menu bar view
The menu bar view
Testing and spying on the menu bar view
The Notes single note view
The single note view
Testing the single note view
Hooking up and running the view tests
Summary
5. Test Stubs and Mocks
Replacing method behaviors with Sinon.JS stubs
Getting started with stubs
The stub API
Faking and verifying behavior with Sinon.JS mocks
Deciding when to mock
The mock API
Testing Backbone.js components with stubs and mocks
Ensuring stubs and mocks are actually bound
The Notes list item view
The list item view
Testing the list item view
The Notes application router
Running the view and router tests
Finding the rest of the Notes application components
A few more Sinon.JS test helpers
Fake timers
Fake servers
The fake server API
Faking the remote backend in a Backbone.js application
Summary
6. Automated Web Testing
The world of testing beyond humans and browsers
Continuous integration
Continuous deployment
Other scenarios
Automating browser environments
Remote controlled web browsers
Simulated browser environments
Headless web browsers
Multiple environment aggregators
Headless testing with PhantomJS
Installing PhantomJS and the supporting tools
Running Backbone.js tests with PhantomJS
Automating tests in the code samples
Parting thoughts, next steps, and future ideas
Summary
Index

Backbone.js Testing

Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2013
Production Reference: 1050713
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-524-8
www.packtpub.com
Cover Image by Robin Chin Roemer ()

Credits

Author
Ryan Roemer
Reviewers
Casey Foster
Jim Newbery
Acquisition Editor
Martin Bell
Commissioning Editor
Shreerang Deshpande
Technical Editor
Sumedh Patil
Copy Editors
Insiya Morbiwala
Alfida Paiva
Laxmi Subramanian
Project Coordinator
Sneha Modi
Proofreaders
Maria Gould
Paul Hindle
Indexer
Tejal Soni
Production Coordinator
Arvindkumar Gupta
Cover Work
Arvindkumar Gupta

About the Author

Ryan Roemer is the Director of Engineering at Curiosity Media, a language learning startup, where he manages technical operations and leads the development team. He develops (and tests) full-stack JavaScript applications and backend Node.js services. He also works with data mining, cloud architectures, and problems related to large scale distributed systems.
He was previously an engineer in the cloud computing storage group of Microsoft's Azure platform and most recently developed the search and cloud architecture for IP Street, a patent data mining startup. Besides engineering, he is a registered patent attorney (inactive), although it has been a long...

Table des matiĂšres