Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

92 CHAPTER 3 Getting started with JavaScript


FIGURE 3-5 he QUnit summary screen showing 0 tests of 0 passed, 0 failedT

This screen is showing that no tests have passed and no tests have failed because you have
no tests yet. It’s time to add a Hello World test to the application.
A default.js file and a tests.js file need to be added to the Scripts folder by right-clicking
the Scripts folder and choosing Add. Choose the JavaScript file. Name the file default.js and
click OK. Do the same for the tests.js file.
A reference to these files needs to be added to the default.html file. With the default.html
file open, drag the default.js file out to the source of the default.html file and drop the file
right after the last ending script tag (</script>). Drag the tests.js file out and drop it after the
last ending script tag. Your results should look like the following, in which the inserted lines
are bold:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="Content/qunit.css" />
<script src="Scripts/qunit.js"></script>
<script src="Scripts/default.js"></script>
<script src="Scripts/tests.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit example</h1>
Free download pdf