[英]Angular/Karma: Error: [$injector:nomod] Module 'module' is not available
所以我試圖在我的Angular項目中使用Karma測試運行器,但我一直收到這個錯誤:
錯誤:[$ injector:nomod]模塊'app.auth'不可用! 您要么錯誤拼寫了模塊名稱,要么忘記加載它。 如果注冊模塊,請確保將依賴項指定為第二個參數。
我在腳本文件夾中有我的所有.js
文件,我的karma.conf.js
指向,但由於某種原因,我不斷收到該錯誤。
我的karma.conf.js
文件如下所示:
module.exports = function(config) {
config.set({
basePath: '.',
frameworks: ['mocha'],
files: [
'../bower_components/angular/angular.js',
'../bower_components/jquery/dist/jquery.js',
'../bower_components/angular-mocks/angular-mocks.js',
'../scripts/app.module.js',
'../scripts/**/*.js',
'./unit/*.js'
],
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
concurrency: Infinity
})
}
有沒有人知道可能導致這個問題的原因?
任何幫助表示贊賞。 提前致謝!
你能提供你想要運行的規范嗎? 通常,在規范中未加載相應模塊時會發生此錯誤。
嘗試在beforeEach塊中加載角度模塊
beforeEach(angular.mock.module('app.auth'));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.