Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MASTERING KNOCKOUTJS

You're reading from   MASTERING KNOCKOUTJS Use and extend Knockout to deliver feature-rich, modern web applications

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783981007
Length 270 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Timothy Moran Timothy Moran
Author Profile Icon Timothy Moran
Timothy Moran
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Knockout Essentials 2. Extending Knockout with Custom Binding Handlers FREE CHAPTER 3. Extending Knockout with Preprocessors and Providers 4. Application Development with Components and Modules 5. Durandal – the Knockout Framework 6. Advanced Durandal 7. Best Practices 8. Plugins and Other Knockout Libraries 9. Under the Hood Index

Writing unit tests


If you follow all the previous recommendations, then your code will be in a good position to be unit tested. The primary consideration while writing unit testable code is mockability: code whose external dependencies are loosely coupled. Loosely coupled dependencies can be replaced in a unit test with a fake, stub, mock, spy, or other form of replacement whose behavior can be controlled by the test. This challenge is solved by keeping DOM and binding the code out of your viewmodel, keeping the modules small and avoiding tight coupling to other viewmodels through practices such as dependency injection.

There are several frameworks that are available for unit testing in JavaScript, and they all offer similar benefits and workflows. The important thing is not what tools you use to unit test, only that you write unit tests. The value of unit testing really can't be overstated. It is even more important in dynamic languages such as JavaScript that do not offer compile-time checking...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime