安装 Jasmine 失败
Installing Jasmine failing
我正在尝试让 Jasmine 在我的网站上运行。这是我的 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>
和HelloWorldSpec.js:
function helloWorld() {
return "Hello world!";
}
describe("Hello world", function () {
it("says hello", function () {
expect(helloWorld()).toEqual("Hello world!");
});
});
当我加载此页面时,我得到:
ReferenceError: jasmineRequire is not defined
ReferenceError: describe is not defined
我以为我对 JS 文件的引用有误。但是,当我查看页面源代码并单击其中一个 js 链接(例如“/Scripts/UnitTesting/boot.js”)时,我看到了源代码,因此文件似乎已成功加载。这里出了什么问题?
boot.js
文件应该在 jasmine.js
和 jasmine-html.js
之后加载,否则它会启动什么?您应该包含文件的正确顺序是:
jasmine.js
jasmine-html.js
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.
我正在尝试让 Jasmine 在我的网站上运行。这是我的 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>
和HelloWorldSpec.js:
function helloWorld() {
return "Hello world!";
}
describe("Hello world", function () {
it("says hello", function () {
expect(helloWorld()).toEqual("Hello world!");
});
});
当我加载此页面时,我得到:
ReferenceError: jasmineRequire is not defined
ReferenceError: describe is not defined
我以为我对 JS 文件的引用有误。但是,当我查看页面源代码并单击其中一个 js 链接(例如“/Scripts/UnitTesting/boot.js”)时,我看到了源代码,因此文件似乎已成功加载。这里出了什么问题?
boot.js
文件应该在 jasmine.js
和 jasmine-html.js
之后加载,否则它会启动什么?您应该包含文件的正确顺序是:
jasmine.js
jasmine-html.js
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.