【发布时间】:2017-09-05 23:02:44
【问题描述】:
您好,我在使用 AngularJS + Firebase 开发一个简单的 Web 时尝试进行单元测试,但在定义规范和尝试测试运行程序时遇到问题
myProject/test/spec/main.js :
describe('Controller: MainCtrl', function() {
var MainCtrl, scope
beforeEach(module('MainApp'));
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
})
}));
it('should....',function(){
expect(true).toBe(true)
})
it('should2....',function(){
expect(false).toBe(false)
})
});
结果:
PhantomJS 2.1.1 (Mac OS X 0.0.0) Controller: MainCtrl should.... FAILED
Error: [$injector:modulerr] Failed to instantiate module MainApp due
to: Firebase: Firebase App named '[DEFAULT]' already exists
(app/duplicateapp).
但是,定义一次规范不是问题。例如:
it('should....',function(){
expect(true).toBe(true)
})
我不知道为什么这是我给我提示的原因
这是我正在开发的项目。
【问题讨论】:
标签: angularjs unit-testing firebase karma-runner karma-jasmine