Home Page Icon
Home Page
Table of Contents for
Jasmine JavaScript Testing
Close
Jasmine JavaScript Testing
by Paulo Ragonha
Jasmine JavaScript Testing
Jasmine JavaScript Testing
Table of Contents
Jasmine JavaScript 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. Getting Started with Jasmine
JavaScript – the bad parts
Jasmine and Behavior-Driven Development
Downloading and first run
Summary
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
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
4. Asynchronous Testing – AJAX
Setting up the Scenario
Installing Node.js
Coding the server
Running the server
Writing the spec
The waitsFor() function
The runs() function
Summary
5. Jasmine Spies
The "bare" Spy
Spy an object's functions
Testing DOM events
Summary
6. Light Speed Unit Testing
Jasmine Stubs
Sinon.JS
Installing Sinon.JS
A Fake XMLHttpRequest
A Fake server
Summary
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 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
8. Build Automation
RequireJS
Module definition
Project setup
The new SpecRunner.JS file
The RequireJS configuration
Using non AMD dependencies with Shim
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
9. Conclusion
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Table of Contents
Next
Next Chapter
Jasmine JavaScript Testing
Jasmine JavaScript Testing
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset