Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Test-Driven JavaScript Development

You're reading from   Test-Driven JavaScript Development Learn JavaScript test-driven development using popular frameworks and tools

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781782174929
Length 240 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ravi Kumar Gupta Ravi Kumar Gupta
Author Profile Icon Ravi Kumar Gupta
Ravi Kumar Gupta
Arrow right icon
View More author details
Toc

QUnit

QUnit is JavaScript test framework, which can be used to run unit test written in JavaScript. QUnit is used by jQuery, jQuery UI, and jQuery mobile projects. QUnit was originally developed by John Resig as a part of jQuery. QUnit is normally used to test the JavaScript code and it's even used to test server-side JavaScript via some JavaScript engine such as Rhine or V8. Like we have seen in JsUnit, we can run the QUnit test in browser or in command prompt with some test runner such as Karma.

Getting started

To install QUnit in our system, we need to get the QUnit library from jQuery CDN (http://code.jquery.com/qunit/).

Two files are needed to run test with the use of QUnit: qunit.js and quint.css. Once we download these files, then we can start writing our tests.

Writing tests

Let's see how we can write test using QUnit and know about assertions available in QUnit:

  • Assertions: QUnit contains the following assertions that we can use to write any test:
    • async(): Instruct QUnit to...
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 $19.99/month. Cancel anytime