Book Image

JavaScript Unit Testing

By : Hazem Saleh
Book Image

JavaScript Unit Testing

By: Hazem Saleh

Overview of this book

<p>The largest challenge for many developers’ day to day life is ensuring the support of, and assuring the reach of, their product. With the ever increasing number of mainstream web browsers this is becoming a more difficult task for JavaScript coders. <br /><br />From the beginning, JavaScript Unit Testing will show you how to reduce the time you spend testing, and automate and ensure efficiency in guaranteeing your success.<br /><br />JavaScript Unit Testing will introduce and help you master the art of efficiently performing and automating JavaScript Unit tests for your web applications.<br /><br />Using the most popular JavaScript unit testing frameworks, you will develop, integrate, and automate all the tests you need to ensure the widest reach and success of your web application.<br /><br />Covering the most popular JavaScript Unit testing frameworks of today, JavaScript Unit Testing is your bible to ensuring the functionality and success of all of your JavaScript and Ajax Web Applications.<br /><br />Starting with Jasmine, you will also learn about, and use, YUITest, QUnit, and JsTestDriver, integrate them into your projects, and use them together to generate reports.<br /><br />Learn to automate these tools, make them work for you, and include the power of these tools in your projects from day one.</p>
Table of Contents (12 chapters)

Configuration


In order to configure JSTD, you need to follow the ensuing steps:

  1. Download the framework from http://code.google.com/p/js-test-driver/downloads/list. At the time of this writing, the latest release of JSTD is v1.3.4.b. So, the JsTestDriver-1.3.4.b.jar file has been used for working with JSTD in this chapter.

    As recommended in the previous chapters, it is a good habit to separate the JavaScript source and testing files in different folders for the sake of organization.

  2. The second step is to create the JSTD test configuration file, jsTestDriver.conf, as shown in the following code snippet:

    server: http://localhost:9876
    
    load:
      - src/*.js
      - tests/*.js

    The configuration file is in YAML format (YAML is a recursive acronym for YAML Ain't Markup Language. For more information about the YAML format, check http://yaml.org/.). The server directive refers to the JSTD server URL. If the server directive is not specified, the server URL will be needed to be specified at the command line....