[英]Angular/Karma: Error: [$injector:nomod] Module 'module' is not available
So I'm trying to use the Karma test runner on my Angular project, but I keep getting this error: 所以我试图在我的Angular项目中使用Karma测试运行器,但我一直收到这个错误:
Error: [$injector:nomod] Module 'app.auth' is not available!
错误:[$ injector:nomod]模块'app.auth'不可用! 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.
如果注册模块,请确保将依赖项指定为第二个参数。
I have all my .js
files in a scripts folder, that my karma.conf.js
is pointing to, but for some reason I keep getting that error. 我在脚本文件夹中有我的所有
.js
文件,我的karma.conf.js
指向,但由于某种原因,我不断收到该错误。
My karma.conf.js
file looks like this: 我的
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
})
}
Does anyone have an idea of what might be causing this issue? 有没有人知道可能导致这个问题的原因?
Any help is appreciated. 任何帮助表示赞赏。 Thanks in advance!
提前致谢!
Could you please provide the spec that you are trying to run. 你能提供你想要运行的规范吗? Generally this error occurs when respective module is not loaded in the spec.
通常,在规范中未加载相应模块时会发生此错误。
Try loading the angular module in a beforeEach block 尝试在beforeEach块中加载角度模块
beforeEach(angular.mock.module('app.auth'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.