Jasmine JavaScript Testing


Jasmine JavaScript Testing
eBook: $19.99
Formats: PDF, PacktLib, ePub and Mobi formats
$16.99
save 15%!
Print + free eBook + free PacktLib access to the book: $53.98    Print cover: $33.99
$33.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn the power of test-driven development while creating a fully-featured web application
  • Understand the best practices for modularization and code organization while putting your application to scale
  • Leverage the power of frameworks such as BackboneJS and jQuery while maintaining the code quality
  • Automate everything from spec execution to build; leave repetition to the monkeys

Book Details

Language : English
Paperback : 146 pages [ 235mm x 191mm ]
Release Date : August 2013
ISBN : 178216720X
ISBN 13 : 9781782167204
Author(s) : Paulo Ragonha
Topics and Technologies : All Books, Application Development, Open Source

Table of Contents

Preface
Chapter 1: Getting Started with Jasmine
Chapter 2: Your First Spec
Chapter 3: Testing Frontend Code
Chapter 4: Asynchronous Testing – AJAX
Chapter 5: Jasmine Spies
Chapter 6: Light Speed Unit Testing
Chapter 7: Testing Backbone.js Applications
Chapter 8: Build Automation
Chapter 9: Conclusion
Index
    • Chapter 2: Your First Spec
      • The Investment Tracker application
      • Jasmine basics and thinking in BDD
      • Setup and teardown
      • Nested describes
        • Setup and teardown
        • Coding a spec with shared behavior
      • Understanding matchers
        • Custom matchers
        • Built-in matchers
          • The toEqual built-in matcher
          • The toBe built-in matcher
          • The toBeTruthy and toBeFalsy matchers
          • The toBeUndefined, toBeNull, and toBeNaN built-in matchers
          • The toBeDefined built-in matcher
          • The toContain built-in matcher
          • The toMatch built-in matcher
          • The toBeLessThan and toBeGreaterThan built-in matchers
          • The toThrow built-in matcher
      • Summary
      • Chapter 3: Testing Frontend Code
        • Thinking in terms of components (Views)
        • The module pattern
        • Using HTML fixtures
        • Basic View coding rules
          • The View should encapsulate a DOM element
          • Integrate Views with observers
        • Testing Views with jQuery matchers
          • The toBe jQuery matcher
          • The toContainHtml jQuery matcher
          • The toContain jQuery matcher
          • The toHaveValue jQuery matcher
          • The toHaveAttr jQuery matcher
          • The toBeFocused jQuery matcher
          • The toBeDisabled jQuery matcher
          • More matchers
        • Summary
              • Chapter 7: Testing Backbone.js Applications
                • The Backbone model
                  • Declaring a new model
                  • The model attributes
                  • Default attribute values
                  • Events
                  • Sync and AJAX requests
                • Testing Backbone collections
                  • Declaring a new collection
                  • Sync and AJAX requests
                • Testing Backbone Views
                  • Declaring a new View
                  • The el property
                  • Rendering
                  • Updating the View on model changes
                  • Binding DOM events
                • Testing Backbone routers
                  • Defining a new router
                  • Defining routes
                  • Using routers
                  • Routers should only route
                • Summary
                • Chapter 8: Build Automation
                  • RequireJS
                    • Module definition
                    • Project setup
                      • The new SpecRunner.JS file
                      • The RequireJS configuration
                    • Testing a module
                    • Optimizing for production
                  • Headless testing with PhantomJS
                    • Downloading and installing PhantomJS
                    • Running your tests without opening a browser
                  • Grunt
                    • Installation
                    • Project setup
                    • A RequireJS optimizer task
                    • A Jasmine task
                    • Watch for changes and run the specs
                  • Managing NPM dependencies
                  • Summary

                  Paulo Ragonha

                  Paulo Ragonha is a software engineer. He loves web development for the opportunities that it carries; "to be able to craft a piece of software that can be instantly accessible by anyone" (with internet connection, of course). In his early days of software development, he was mostly involved in game development and Java. But since his discovery of Ruby and JavaScript, he has worked uniquely on web applications. His last three projects were big JavaScript applications, developed entirely driven by tests and with amazing tooling support. He has an amazing wife that he loves very much, lives in the beautiful Florianópolis, a coast city in the south of Brazil. He is a casual speaker, a biker, a runner, and a hobbyist photographer (he has earned an actual award taking pictures).
                  Sorry, we don't have any reviews for this title yet.

                  Code Downloads

                  Download the code and support files for this book.


                  Submit Errata

                  Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                  Errata

                  - 8 submitted: last submission 03 Feb 2014

                  Errata Category: Typo       Page number: 42

                  Instead of

                  This pattern is also knows as the module pattern...

                  it should be

                  This pattern is also known as the module pattern...

                  Errata Category: Code       Page Number: 45

                  in the fifth line of the HTML code,

                   

                  Instead of

                  <input type="text" class="new-investment-sti ock-symbol"

                   

                  it should be

                  <input type="text" class="new-investment-stock-symbol"

                   

                  Errata Category: Code      Page numbers: 58, 60, 61, 63, 64

                   

                  every instance of 23.66 or 23.67 should actually be 20.18.

                  Errata Category: Technical      Page numbers: 3

                  Section : What this book covers

                  Chapter number : 12

                  it should be

                  https://www.packtpub.com/sites/default/files/downloads/7204OS_The_Future_Jasmine_2_0.pdf

                  instead of

                  http://www.packtpub.com/sites/default/files/downloads/7204OS_The_Future _Jasmine_2_0.pdf 

                  Errata Category: Code      Page numbers: 20

                  function Investment (parameters) {
                   var params = parameters || {};
                   this.stock = params.stock;
                  }

                  instead of

                  function Investment (params) {
                  var params = params || {};
                  this.stock = params.stock;
                  };

                  Errata Category: Code      Page numbers: 21

                  function Investment (parameters) {
                    var params = parameters || {};
                    this.stock = params.stock;
                    this.shares = params.shares;
                  }

                  instead of

                  function Investment (params) {
                  var params = params || {};
                  this.stock = params.stock;
                  this.shares = params.shares;
                  };

                  Errata Category: Code      Page numbers: 23

                  function Investment (parameters) {
                    var params = parameters || {};
                    this.stock = params.stock;
                    this.shares = params.shares;
                    this.sharePrice = params.sharePrice;
                    this.cost = this.shares * this.sharePrice;
                  }

                  instead of

                  function Investment (params) {
                  var params = params || {};
                  this.stock = params.stock;
                  this.shares = params.shares;
                  this.sharePrice = params.sharePrice;
                  this.cost = this.shares * this.sharePrice;
                  };

                  Errata Category: Technical      Page numbers: 59

                   http://127.0.0.1:8000/stocks/AOUE

                  instead of

                   http://0.0.0.0:8000/stocks/AOUE

                  Sample chapters

                  You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                  Frequently bought together

                  Jasmine JavaScript Testing +    Mastering Web Application Development with AngularJS =
                  50% Off
                  the second eBook
                  Price for both: ₨289.40

                  Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                  What you will learn from this book

                  • 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

                  In Detail

                  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.

                  Approach

                  The book uses a concise, to-the-point approach to help developers understand and use the power of Jasmine to create better and more maintainable codebases.

                  Who this book is for

                  This book is a must-have guide for web developers who are new to the concept of unit testing. It’s assumed that you have a basic knowledge of JavaScript and HTML.

                  Code Download and Errata
                  Packt Anytime, Anywhere
                  Register Books
                  Print Upgrades
                  eBook Downloads
                  Video Support
                  Contact Us
                  Awards Voting Nominations Previous Winners
                  Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                  Resources
                  Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software