Recently, I like using JUnit to Tdd,js on Java as well. I felt jquery was good before, so using Qunit is probably the most famous.
First, log in to the official website http://qunitjs.com/, download two files:
Qunit-1.15.0.js
Qunit-1.15.0.cssIn fact, the qunit framework of these two things.
Then write an HTML and a JS in the reference Getting Started:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.15.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="//code.jquery.com/qunit/qunit-1.15.0.js"></script>
<script src="tests.js"></script>
</body>
</html>
Note that it is better to change the path to
<linkrel="stylesheet" href="Qunit-1.15.0.css">
<scriptsrc="Qunit-1.15.0.js"></Script >
Otherwise, it is possible to fail.
Then create a new tests.js, note that the name is not mistaken, I wrote for Test.js for a few minutes
"hello test"function( assert ) {
1"1""Passed!" );
});
Then you can see the test page:
Getting Started with Qunit