我试图关注这个关于在 ASP.NET MVC 应用程序的单独程序集中使用 requirejs 和 jasmine 的博客。
这是我的 SpecRunner.html:
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
<script type="text/javascript" src="../Beryllium.Web/Scripts/require.js"></script>
<!-- include source files here... -->
<!-- include spec files here... -->
<script type="text/javascript">
require.config({
baseUrl: '../Beryllium.Web/App/ViewModels',
paths: {
spec: '../../Beryllium.Web.UnitTests/spec'
}
})
</script>
<script type="text/javascript">
require(['spec/PlayerSpec', 'spec/SpecHelper'], function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
});
</script>
Beryllium.Web 是 MVC 应用程序,Beryllium.Web.UnitTests 是我的测试程序集。
当我加载 SpecRunner 文件时,我的页面上有 2 个错误:
GET file:///D:/code/Beryllium/Beryllium.Web/Beryllium.Web.UnitTests/spec/PlayerSpec.js require.js:1880
Uncaught Error: Script error for: spec/PlayerSpec
http://requirejs.org/docs/errors.html#scripterror
SpecHelper.js 也出现同样的错误
我的 PlayerSpec.js 是这样开始的:
define(['Player', 'Song'], function(Player, Song) {
describe("Player", function() {
var player;
var song;
beforeEach(function() {
player = new Player();
song = new Song();
});
有没有办法找出究竟是什么导致了这个错误?当我加载 SpecRunner 文件时,页面是空白的,我只能通过打开控制台看到这个错误。