【发布时间】:2015-02-25 20:08:57
【问题描述】:
我正要在我的项目中进行单元测试。 我写的只是一个简单的测试代码。 但是,出现了奇怪的消息: ReferenceError : 描述未定义。
我该如何克服这个问题?
这是我的代码:
'use strict';
(function() {
//Cal test Controller Spec
describe('Cal test Controller Tests',function(){
//Initialize global variables
var CalTestController,
scope;
//Then we can start by loading the main application module
beforeEach(module(ApplicationConfiguration.applicationModuleName));
//The injector ignores leading and trailing underscores here(i.e._$httpBackend_).
//This allows us to inject a service but then attach to it to a variable.
//with the same name as the service.
beforeEach(inject(function($controller,$rootScope){
//Set a new global scope
scope=$rootScope.$new();
//Initialize the Cal test controller.
CalTestController = $controller('CalController',{
$scope:scope
});
}));
var a;
it('contains spec with an expectation',inject(function(){
a = true;
expect(a).toBe(true);
}));
});
describe("The 'toBe' matcher compares with===",function(){
it("and has a positive case",function(){
expect(true).toBe(true);
});
it("and can have a negative case",function(){
expect(false).not.toBe(true);
});
});
}());
【问题讨论】:
-
Jasmine 引用尚未加载。
标签: javascript angularjs karma-jasmine