这是我的模块:
// app.module.js
angular.module('app', ['firebase']);我配置了这样的业力:
// karma.conf.js
files: [
  'bower_components/angular/angular.js',
  'bower_components/firebase/firebase.js',
  'bower_components/angular-mocks/angular-mocks.js',
  'src/**/*.js'
],这是我的考验:
// data.service.spec.js
describe('dataservice', function () {
var dataservice;
beforeEach(module('app'));
beforeEach(function () {
    inject(function (_dataservice_) {
        dataservice = _dataservice_;
    });
});
describe('getData()', function () {
    it('should return an object', function () {
        expect(typeof dataservice.getData()).to.equal('object');
    });
});});
在“业力启动-日志级调试”之后,我得到了错误:
PhantomJS 2.1.1 (Linux 0.0.0) dataservice "before each" hook for "should return an object" FAILED
[$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module fire/home/me/Documents/web/my-app due to:
[$injector:nomod] Module 'fire/home/me/Documents/web/my-app' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.如果删除app.module.js中的防火墙注入,则测试是绿色的。
我在这里做错什么了?
发布于 2016-02-25 22:43:27
你只是运气不好。
您收到一条非常奇怪的消息的原因是,在某些业力版本中,当打印输出给记者时,它将字符串“基”替换为{无论您的基是什么}的错误(请参阅此问题)。
所以角抛出这个错误:
 module firebase但因果报应印有:
 module fireD:/Documents/web/app把你弄糊涂了!
获得该错误的原因是您还需要加载angularfire:
'bower_components/firease/firebase.js',
'bower_components/angularfire/dist/angularfire.js(您将firebase拼错为firease)
我建议您将业力更新为最新版本(尽管该bug显然是在某个阶段重新出现)。
顺便说一句,Karma通常不太擅长告诉您什么时候找不到文件,但是您可以在更高的日志级别上运行它,它告诉您它实际上在哪里查找文件:
karma start --log-level DEBUG发布于 2016-02-22 04:11:03
错误/异常是由角度引起的,所以请检查您是否在webapp中引用了firebase.js,而不仅仅是karma.conf.js的files部分。
https://stackoverflow.com/questions/35545147
复制相似问题