MarsRover.js
var marsRover = function() {
return 0;
};
MarsRoverSpec.js(这不起作用)
describe("MarsRover Kata Tests", function() {
it("has function named marsRover", function() {
expect(marsRover()).toBe(0);
});
});
以上代码不起作用:ReferenceError:未定义marsRover
MarsRoverSpec.js(这可行)
var marsRover = function() {
return 0;
};
describe("MarsRover Kata Tests", function() {
it("has function named marsRover", function() {
expect(marsRover()).toBe(0);
});
});
我猜我需要包含或要求JS文件。什么是最好或最简单的方法?
HTML
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v2.0.0</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.0/jasmine.css">
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine-html.js"></script>
<script type="text/javascript" src="lib/jasmine-2.0.0/boot.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="../Mars Rover/src/MarsRover.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="../Mars Rover/spec/MarsRoverSpec.js"></script>
</head>
<body>
</body>
</html>
答案 0 :(得分:0)
我在应用的根目录中有一个重复的MarsRover.js文件。不知道为什么这是一个问题,因为我在html中明确指定js文件在src文件夹中。