O'Reilly logo

JavaScript Testing by Liang Yuxian Eugene

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action testing JavaScript with QUnit

In this section, we'll learn more about QUnit, by writing a bit of code, and the also learn about various tests that QUnit supports. We will write tests that are correct and tests that are and wrong, in order to see how it works. The source code for this section can be found in the source code folder qunit.

  1. Open your editor and save the file as example.html. Enter the following code in it:
    <!DOCTYPE html>
    <html>
    <head>
    <title>QUnit Example</title>
    <link rel="stylesheet" href="http://github.com/jquery/qunit/raw/master/qunit/qunit.css" type="text/css" media="screen">
    <script type="text/javascript" src="http://github.com/jquery/qunit/raw/master/qunit/qunit.js"></script>
     <script type="text/javascript" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required