yesman
yesman

Reputation: 7829

Installing Jasmine failing

I'm trying to get Jasmine to work on my website. This is my HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.1.3</title>
<link rel="stylesheet" type="text/css" href="/Content/css/jasmine.css" />
<script src="/Scripts/UnitTesting/boot.js"></script>
<script src="/Scripts/UnitTesting/jasmine-html.js"></script>
<script src="/Scripts/UnitTesting/jasmine.js"></script>
<!-- include source files here... -->

<!-- include spec files here... -->
<script src="/Scripts/UnitTesting/HelloWorldSpec.js"></script>

</head>
<body>
</body>
</html>

And HelloWorldSpec.js:

function helloWorld() {
    return "Hello world!";
}

describe("Hello world", function () {
    it("says hello", function () {
        expect(helloWorld()).toEqual("Hello world!");
    });
});

When I load this page, I get:

ReferenceError: jasmineRequire is not defined
ReferenceError: describe is not defined

I thought I got the reference to the JS files wrong. But when I look at the page source, and click on one of the js links, for example, "/Scripts/UnitTesting/boot.js", I see the source code, so it appears the files are loaded succesfully. What's going wrong here?

Upvotes: 1

Views: 56

Answers (1)

Oleg
Oleg

Reputation: 9359

The boot.js file should be loaded after jasmine.js and jasmine-html.js Otherwise what would it boot? The correct order that you should include the files is:

  1. jasmine.js
  2. jasmine-html.js
  3. boot.js

http://jasmine.github.io/2.0/boot.html

Starting with version 2.0, this file “boots” Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project’s specs. This file should be loaded after jasmine.js and jasmine_html.js, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.

Upvotes: 2

Related Questions