Reputation: 223
I work for a E-Com company that uses .NET MVC with some legacy Webforms applications, augmented by JavaScript. We currently have no test coverage of any of our JavaScript, as there is quite a lot of it, we thought it best to look in to something to cover that too.
I've been trying to follow some videos on JavaScript Client-Side Unit Testing. One of them was a Pluralsight course that covered some QUnit.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>QUnit Main Test Suite</title>
<link rel="stylesheet" href="qunit.css">
<script src="tests.js"></script>
<script src="qunit.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
</body>
</html>
Ok so here's my tests.html html file, I've got the qunit.css and qunit.js files in the same directory.
Here is my tests.js file, something incredibly simple (as per the video I was following)
test('my first test', function(assert) {
var value = "hello";
assert.equal( value, "hello", "We expect value to be hello");
});
What I get though, when I run up the tests.html file (first code snippet) is this:
I've tried adding in some of the other tests that get provided with the QUnit zip, once included they start showing up, but my test does not. My first thought was perhaps the syntax was incorrect, so I replicated one of the examples that does work when included, this still didn't work for me though.
Perhaps I'm misunderstanding something, or have missed something here, any help would be much appreciated.
Thank you.
Upvotes: 0
Views: 646
Reputation: 223
Thanks to mparnisari for pointing this out. This was because of the ordering of my script. The qunit.js script needed to be included first, then my tests.js file.
Upvotes: 2