JavaScript Unit Testing


JavaScript Unit Testing
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
$12.74
save 15%!
Print + free eBook + free PacktLib access to the book: $44.98    Print cover: $29.99
$29.99
save 33%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn and understand, using practical examples, synchronous and asynchronous JavaScript unit testing
  • Cover the most popular JavaScript Unit Testing Frameworks including Jasmine, YUITest, QUnit, and JsTestDriver
  • Automate and integrate your JavaScript Unit Testing for ease and efficiency

Book Details

Language : English
Paperback : 190 pages [ 235mm x 191mm ]
Release Date : January 2013
ISBN : 1782160620
ISBN 13 : 9781782160625
Author(s) : Hazem Saleh
Topics and Technologies : All Books, App Testing, Web Development, Java, Open Source

Table of Contents

Preface
Chapter 1: Unit Testing JavaScript Applications
Chapter 2: Jasmine
Chapter 3: YUI Test
Chapter 4: QUnit
Chapter 5: JsTestDriver
Index
  • Chapter 1: Unit Testing JavaScript Applications
    • What unit testing is
    • Why we need unit testing
    • What Test-Driven Development (TDD) is
    • Complexities in testing JavaScript applications
    • Weather forecasting application
      • Exploring the application's HTML and JavaScript code
      • Running the weather application
    • Summary
    • Chapter 2: Jasmine
      • Configuration
      • Writing your first Jasmine test
      • The nested describe blocks
      • Jasmine matchers
        • The toBe matcher
        • The toBeDefined and toBeUndefined matchers
        • The toBeNull matcher
        • The toBeTruthy and toBeFalsy matchers
        • The toContain matcher
        • The toBeLessThan and toBeGreaterThan matchers
        • The toMatch matcher
        • Developing custom Jasmine matchers
      • Testing asynchronous (Ajax) JavaScript code
        • The runs() function
        • The waits() function
        • The waitsFor() function
        • The spyOn() function
      • HTML fixtures
        • Configuring the jasmine-jquery plugin
        • The loadFixtures module
      • Testing the weather application
        • Testing the LoginClient object
        • Testing the RegistrationClient object
        • Testing the WeatherClient object
        • Running the weather application tests
      • Summary
      • Chapter 3: YUI Test
        • Writing your first YUI test
        • Assertions
          • The assert assertion
          • The areEqual and areNotEqual assertions
          • The areSame and areNotSame assertions
          • The datatype assertions
          • Special value assertions
          • The fail assertion
        • Testing asynchronous (Ajax) JavaScript code
          • The wait and resume functions
        • Testing the weather application
          • Testing the LoginClient object
          • Testing the RegistrationClient object
          • Testing the WeatherClient object
          • Running the weather application tests
          • Generating test reports
        • Automation and integration with build management tools
          • Configuring YUI Test Selenium Driver
          • Using YUI Test Selenium Driver in the weather application
          • Integration with build management tools
        • Summary
        • Chapter 4: QUnit
          • Configuration
          • Writing your first QUnit test
          • Assertions
            • The ok assertion
            • The equal and notEqual assertions
            • The deepEqual and notDeepEqual assertions
            • The expect assertion
            • Developing custom QUnit assertions
          • Testing asynchronous (Ajax) JavaScript code
            • The stop and start APIs
          • Testing the weather application
            • Testing the LoginClient object
            • Testing the RegistrationClient object
            • Testing the WeatherClient object
            • Running the weather application tests
          • Summary
          • Chapter 5: JsTestDriver
            • Architecture
            • Configuration
            • Writing your first JSTD test
            • Assertions
              • The assert, assertTrue, and assertFalse([msg], expression) assertions
              • The assertEquals and assertNotEquals([msg], expected, actual) assertions
              • The assertSame and assertNotSame([msg], expected, actual) assertions
              • The datatype assertions
              • Special value assertions
              • The fail([msg]) assertion
            • Testing asynchronous (Ajax) JavaScript code
              • AsyncTestCase, queue, and callbacks
            • Testing the weather application
              • Testing the LoginClient object
              • Testing the RegistrationClient object
              • Testing the WeatherClient object
              • Configuring the proxy
              • Running the weather application tests
              • Generating test reports
            • Integration with other JavaScript test frameworks
              • Integrating JSTD with Jasmine
              • Integrating JSTD with QUnit
            • Integration with build management tools
            • Integration with the IDEs
              • Eclipse integration
            • Summary

            Hazem Saleh

            Hazem Saleh has 9 years of experience in JEE and open source technologies. He has worked as a technical consultant for different clients in Europe (Sweden), North America (USA, Canada), South America (Peru), Africa (Egypt), and Asia (Qatar, Kuwait). He is an Apache MyFaces committer, and the founder of many open source projects. Besides being the co-author of the book The Definitive Guide to Apache MyFaces and Facelets, Zubin Wadia, Martin Marinschek, Hazem Saleh, Dennis Byrne, Apress and the author of this book, Hazem is also an author of many technical articles, a developerWorks contributing author, and a technical speaker at both local and international conferences, such as the IBM Regional Technical Exchange, CONFESS, and JavaOne. Hazem is now working for IBM Egypt (Cairo Lab SWG Services) as an Advisory Software Engineer. He is a Web 2.0 subject matter expert and an IBM Certified Expert IT Specialist.
            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.

            Sorry, there are currently no downloads available for this title.

            Frequently bought together

            JavaScript Unit Testing +    Mastering Web Application Development with AngularJS =
            50% Off
            the second eBook
            Price for both: £19.45

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

            What you will learn from this book

            • Learn and use the power of Jasmine, YUITest, QUnit, and JsTestDriver
            • Learn by doing to synchronously and asynchronously test your JavaScript applications
            • Automate your JavaScript tests using both Build and Integration Management Tools
            • Generate test reports for your JavaScript tests
            • Customize JavaScript unit testing frameworks to include rich test expressions

            In Detail

            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.

            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.

            JavaScript Unit Testing will introduce and help you master the art of efficiently performing and automating JavaScript Unit tests for your web applications.

            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.

            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.

            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.

            Learn to automate these tools, make them work for you, and include the power of these tools in your projects from day one.

            Approach

            A practical, example-driven guide to using, automating, and integrating JavaScript Unit tests for the busy and conscientious JavaScript developer striving for excellence and success.

            Who this book is for

            JavaScript Unit Testing is a must have guide for every web developer, designer, architect, and JavaScript coder seeking to ensure the highest  quality of their web applications and JS code. Knowledge of JavaScript is assumed.

            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