HTML and CSS Reference
This method of working really helps you to write much cleaner code, as your
code will now be written to satisfy only the expected output.
Writing Your First Unit Test
You can either choose to write your own unit-testing framework or use one
that's readily available. The choice for this topic is QUnit. It has been developed
by the jQuery community and has regular updates. Not only this, but it can be
run from the browser, or optionally, can be run from the command line using a
program called PhantomJS.
To set up a QUnit unit test for the calculator, first create a new file called
calculator.html in the tests folder containing the following HTML.
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>calculator unit tests</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-
scale=1.0; user-scalable=0; target-densitydpi=device-dpi;"/>
<!-- Include the latest QUnit CSS file -->
<link href=" http://code.jquery.com/qunit/qunit-git.css" re l="stylesheet"
<h1 id="qunit-header">calculator unit tests</h1>
<div id="qunit-fixture"><!-- If you have DOM that needs to be manipulated,
this is where it should go --></div>