Posted in JavaScript

QUnit introduce

QUnit

  • What is QUnit?

QUnit is a powerful, easy-to-use JavaScript unit testing framework. It’s used by the jQuery, jQuery UI and jQuery Mobile projects and is capable of testing any generic JavaScript code.

Refer: QUnit site

  • Install QUnit using NPM:

npm install -g qunit

  • Hello World Demo:

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.5.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.5.0.js"></script>
<script src="tests.js"></script>
</body>
</html>

helloworld.js

QUnit.test( "hello test", function( assert ) {
assert.ok( 1 == "1", "Passed!" );
});

 

Simply run Demo by open index.html file in Brower. Refer:

qunit_result

You also file the demo at HelloWorld at Github

Thank you. Hope it is useful 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s