当我运行SpecRunning时,网页没有显示任何内容,但没有任何错误。 这是我的SpecRunning.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v<%= jasmineVersion %></title>
<link rel="shortcut icon" type="image/png" href="test/images/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="test/lib/jasmine-core/jasmine.css">
<script type="text/javascript" src="test/lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript" src="test/lib/jasmine-core/jasmine-html.js"></script>
<script type="text/javascript" src="test/lib/jasmine-core/boot.js"></script>
<script type="text/javascript" src="app/lib/angular/angular-scenario.js"></script>
<!-- include source files here... -->
<script src="app/js/phoneControllers.js"></script>
<!-- include spec files here... -->
<script src="test/js/phoneControllersSpec.js"></script>
</head>
<body></body>
</html>
这是
phoneControllers.js
function PhoneListCtrl($scope){
$scope.phones=[
{
"name":"SamSung",
"snippet":"Good phone"
},
{
"name":"M",
"snippet":"Small phone"
},
{
"name":"Apple",
"snippet":"American phone"
},
{
"name":"BBK",
"snippet":"Made in China"
}
];
$scope.Hello="Hello,world";
}
describe("PhoneCat controllers", function(){
describe("PhoneListCtrl", function(){
var scope={}, ctrl=new PhoneListCtrl(scope);
it("should create 'phones' model with 4 phones", function(){
expect(scope.phones.length).toBe(4);
});
it("should create 'Hello,world' sentence", function(){
expect(scope.Hello).toEqual("Hello,world");
});
});
});
这是我的phoneControllersSpec.js
describe('PhoneCat App', function(){
describe('Phone list view', function(){
beforeEach(function(){
browser().navigateTo('../../app/Index.html');
});
it('should filter ', function(){
expect(repeater('.phones li').count()).toBe(4);
input('query').enter('SamSung');
expect(repeater('.phones li').count()).toBe(1);
input('query').enter('China');
expect(repeater('.phones li').count()).toBe(1);
});
});
});
如果我删除
<script type="text/javascript" src="app/lib/angular/angular-scenario.js"></script>
来自SpecRunning.html的,它提示“浏览器未定义”。 我该怎么办?提前致谢
答案 0 :(得分:0)
之后我自己解决了这个问题。