因果报应;模块不可用'
Karma complains 'Module is not available'
直到几天前,我的单元测试运行得很好,我的代码在浏览器中运行得很完美。然后我在添加了一个名为"profile"的存根模块后注意到了这一点:
INFO [karma]: Karma v0.12.24 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Mac OS X)]: Connected on socket 7W-0vnkWZaWxYYtwFrhT with id 9336780
PhantomJS 1.9.7 (Mac OS X) ERROR
Error: [$injector:nomod] Module 'profile' 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.
现在,我意识到这是地球上最常见的AngularJS错误,我已经非常擅长调试它,但就我而言,我无法让它消失。详细信息:
- 代码在浏览器中正常工作,没有任何错误
因果报应以这种方式获取我的文件:
'node_modules/angular/angular.js', 'node_modules/angular-mocks/angular-mocks.js', 'node_modules/angular-ui-router/release/angular-ui-router.js', 'node_modules/angular-bootstrap/ui-bootstrap.js', 'node_modules/angular-ui-form-validation/dist/angular-ui-form-validation.js', 'node_modules/angular-animate/angular-animate.js', 'client/app/**/*.js'
主模块已声明对"profile"的依赖项。
- profile.js、profile.controller.js和profile.coontroller.spec.js是由cg-angular fullstack生成的存根,没有特殊代码。生成器默认情况下会将所有这些模块都粘贴在主模块中,因此我将每个模块的模块更改为"profile"
我完全没有主意了。如果我不能调试它,我将不得不假设我的整个应用程序设计有缺陷,然后重新启动。:(
不知何故,Karma没有按照正确的顺序导入文件,尽管这已经持续了几周。我的决心有三个部分:
- 已将所有模块定义从*.js重命名为*.module.js
- 将不在模块定义中的所有UI路由器工作从*.js重命名为*.state.js
-
按以下顺序导入的文件:
'node_modules/jquery/dist/jquery.js', 'node_modules/angular/angular.js', 'node_modules/angular-mocks/angular-mocks.js', 'node_modules/angular-ui-router/release/angular-ui-router.js', 'node_modules/angular-bootstrap/ui-bootstrap.js', 'node_modules/angular-ui-form-validation/dist/angular-ui-form-validation.js', 'node_modules/angular-animate/angular-animate.js', // client files 'client/app/app.module.js', 'client/app/app.controller.js', 'client/app/**/*.service.js', 'client/app/**/*.directive.js', 'client/app/**/*.module.js', 'client/app/**/*.state.js', 'client/app/**/*.controller.js', 'client/app/**/*.spec.js'
直到那时,测试才重新开始工作。
相关文章:
- 为什么不'当单元测试出现解析错误时,我的因果报应测试会失败
- 因果报应-找不到模块:错误:无法解析模块'scs'
- 如何将因果报应测试报告上传到声纳
- 因果报应,幻影JS和es6承诺
- AngularJS因果报应测试规范承诺未解析,且未调用.then()
- 如何使用console.log在因果报应测试中检查函数
- $routeUpdate未在角因果报应单元测试中广播
- 因果报应测试
- 通过因果报应测试管理angularjs控制器初始化
- 因果报应并没有执行测试用例
- ngRoute不是因果报应实例化的
- 巴贝尔/因果报应/柴给出类型错误:'呼叫者''被叫',和'自变量'在严格模
- 因果报应-如何指向类型脚本覆盖的源地图
- 无法让因果报应运行我的Angular2测试
- 如何用新版本的因果报应取代被弃用的吞咽因果报应
- 将角度控制器添加到因果报应覆盖(伊斯坦布尔)代码覆盖预处理器
- 因果报应;模块不可用'
- 角度/因果报应:错误:[$injector:nomod]模块'模块'不可用
- 使用$httpBackend+$资源进行角因果报应单元测试,而不使用模块进行自举
- 因果报应:在相对路径中找不到模块