Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 模拟角度模块以通过业力测试_Angularjs_Flash_Module_Mocking_Karma Jasmine - Fatal编程技术网

Angularjs 模拟角度模块以通过业力测试

Angularjs 模拟角度模块以通过业力测试,angularjs,flash,module,mocking,karma-jasmine,Angularjs,Flash,Module,Mocking,Karma Jasmine,我最近在我的控制器中实现了flash消息,这导致我所有的业力测试都失败了。我看到另一篇帖子建议制作一个假模块并将其注入,但这似乎不是最佳实践 有没有一种简单的方法可以模仿我的控制器发出的“角度闪光” 编辑: 这是堆栈错误的开始: Error: [$injector:modulerr] Failed to instantiate module ShopTill due to: Error: [$injector:modulerr] Failed to instantiate module

我最近在我的控制器中实现了flash消息,这导致我所有的业力测试都失败了。我看到另一篇帖子建议制作一个假模块并将其注入,但这似乎不是最佳实践

有没有一种简单的方法可以模仿我的控制器发出的“角度闪光”

编辑:

这是堆栈错误的开始:

Error: [$injector:modulerr] Failed to instantiate module ShopTill due to:
    Error: [$injector:modulerr] Failed to instantiate module flash due to:
    Error: [$injector:nomod] Module 'flash' 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.
    http://errors.angularjs.org/1.4.0/$injector/nomod?p0=flash
        at /Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:1955
        at ensure (/Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:1877)
        at module (/Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:2192)
        at /Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:4338
        at forEach (/Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:336)
        at loadModules (/Users/edobrien/Documents/projects/Clothing-Retailer/bower_components/angular/angular.js:4364)
        at /Users/edobrien/Documents/proj

但当我在localhost上查看时,它是有效的,所以这一定是测试中的一个问题。。。。有什么帮助吗?

您应该模拟控制器所需的注射剂。单元测试应该只关心它正在测试的东西,在你的情况下,你的控制器。是的,但是是注入的模块破坏了测试,或者我需要以某种方式包含模块,或者将其删除。如果控制器没有使用模块中的任何内容,你可以在单元测试中加载模块。我想你们模块中的其他工厂也需要它?我已经在页面中添加了我的堆栈