Book Image

WEB APP TESTING USING KNOCKOUT.JS

By : Roberto Messora
Book Image

WEB APP TESTING USING KNOCKOUT.JS

By: Roberto Messora

Overview of this book

Table of Contents (11 chapters)

Preface

This book is a starting point to meet the most important concepts and frameworks involved in modern web application production.

Delivering a web application nowadays consists of building a complete development environment, starting with a proper design and its testing, and ending with an automated build process.

Every chapter sequentially introduces a library or a tool as a specific building block of the entire environment, proposing concrete examples and development considerations: use a presentation framework with Knockout.JS, unit test in BDD style with Jasmine, design and implement a proper development strategy to achieve good unit testing coverage, and install and configure a build environment based on task automation.

This book shows a solid direction to follow when developing a web application and allows its readers to collect new hints and ideas to improve their own design strategies and delivery process.

What this book covers

Chapter 1, Web Application Testing in the Modern Web, is an introduction to modern web development, showing how important the testing of increasingly complex applications is. In particular, it shows how the classic client-side development based on jQuery is no longer the best solution when unit testing becomes one of the pillars of the implementation strategy. Also, it suggests that a new design approach is needed, based on a JavaScript MV presentation design pattern.

Chapter 2, The Knockout.JS UI Framework Explained, covers the most important features of Knockout.JS, which is the most well-known JavaScript presentation pattern based on Model-View-ViewModel. It also shows how to effectively use this library in a web application and why this is a good choice in terms of unit testing and application design.

Chapter 3, The Jasmine Unit Testing Framework Explained, covers the most important features of Jasmine, a very well-known JavaScript unit testing framework, based on the Behavior Driven Development approach.

Chapter 4, Unit Testing Strategies, is the core chapter of the book. It shows how to strategically deal with the development of a JavaScript web application when unit testing plays a major role. It suggests some important design principles and approaches when developing a sample web application that uses Knockout.JS as the presentation framework and Jasmine for unit testing.

Chapter 5, Setting Up an Effective Testing Environment, shows how to set up an automated testing environment based on Gulp.JS and Karma; the first is a Node.JS module that acts as a task automation system, and the second is a test runner system. It covers the steps needed to install, configure, and execute all of the system components, including unit testing reports and code coverage. It also shows how to directly test the user interface using Phantom.JS and its page automation capabilities.

What you need for this book

This book talks about web application testing. Every piece of code is written in HTML5/JavaScript/CSS3. So basically, you simply need a text editor and modern browser. In particular, the requirements are as follows:

Who this book is for

Web App Testing Using Knockout.JS is intended for every type of JavaScript developers, from experts to beginners, who want to improve their quality standards in terms of solutions design and features correctness. Experts who already know JavaScript design patterns and unit testing can find a valid reference to put everything together in a comprehensive working framework. Beginners who barely know how to manipulate an HTML page with a multipurpose library such as jQuery can find a step-by-step introduction manual that covers all aspects of a delivery process. In general, a basic understanding of web development, HTML, and JavaScript is required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We put the script tags just before the closing body tag for performance reasons."

A block of code is set as follows:

this.myModule = (function (module) {
    module.MyClass = function () {
      //MyClass definition
    }
    return module;
}(this.myModule || {})); 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<p>
   <span>Slider value:</span>
   &nbsp;
   <span id="sliderValue"></span>
   &nbsp;
    <button id="sliderReset">Reset</button>
</p> 

Any command-line input or output is written as follows:

npm install -g gulp 

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the first one, we activate or disable the drop-down menu, whether or not the Foreign radio option is checked."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.