2016-03-05 97 views
0

我在搞業障,無法加載我的文件。我添加了一個文件數組到karma.config.js,我只是看到所有模塊的錯誤:錯誤:[$ injector:nomod]模塊'loginModule'不可用!Karma config找不到文件

'use strict'; 

module.exports = function(config) { 

    config.set({ 
    autoWatch : false, 

    frameworks: ['jasmine'], 

    browsers : ['PhantomJS'], 

    plugins : [ 
     'karma-phantomjs-launcher', 
     'karma-jasmine' 
    ], 

    files: [ 
     './app/index.js', 
     './app/**/*.js', 
     './components/**/*.js' 
    ] 
    }); 
}; 

// login.module.js

angular.module('loginModule', []); 
+0

[Angular模塊在Karma Jasmine測試運行中不可用]的可能副本(http://stackoverflow.com/questions/21700615/angular-module-not-available-in-karma-jasmine-test-run) – angmerica

回答

1

確保您指定的基地爲配置中的屬性:

base: '/' 

base: __dirname 

或者無論指向假定的根。

另外, 確保首先加載您的模塊文件。如果你所有的模塊文件定義與.module.js結束,這樣做:

files: [ 
    './app/index.js', 
    './app/**/*.module.js', 
    './app/**/*.js', 
    './components/**/*.js' 
] 

這很可能是你要使用的模塊在另一個文件中被定義之前。