Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Automating tests with QUnit


Hold on, surely QUnit automates the running of these tests for us anyway?

The answer is yes and no. QUnit automated the tests but only to an extent; we had to run the set of tests manually each time. This is all well and good, but you know what? I'm feeling lazy and don't have the time or inclination to continually run tests by hand, as I am sure you won't either. We can do better than this; it is possible to automate our testing using NodeJS/Grunt and PhantomJS.

Granted, it will take some effort to set up, but it is worth the time saved when tests run automatically as soon as any identified content has been altered.

Let's take a look at what is involved in automating our test:

  1. We'll begin by installing NodeJS. To do this, browse to http://nodejs.org/ and download the appropriate binary for your system; it is available for Windows, Mac OS, and Linux.

  2. Once installed, go ahead and open up the NodeJS command prompt and then change to the qunit folder we created at the...