我正在设置我的Karma配置文件,但我不完全理解存在的一些选项,因为我没有成功测试已经通过ng
Html2JsPreprocessor运行的模板
$templateCached
在ngHtml2JsPreprocessor中,我可以添加一些涉及路径的键值属性.
ngHtml2JsPreprocessor: { stripPrefix: ".*/Went all the way back to the root of my application/",// moduleName: 'templatesCached'// },
我现在注释掉模板,以确保我可以访问每个文件作为模块.我正在加载模块没有错误.我可以在我的开发工具中找到templateCached版本.
beforeEach(module('template'));
我的Templates文件夹位于我创建的基道之外.
basePath: 'Scripts/',
我在预处理器对象中引用它
preprocessors: { '../Templates/**/*.html' : ['ng-html2js'] },
我的所有模板现在都是js文件和缓存.
我在package.json里面把文件保存为
save-dev "karma-chrome-launcher": "^0.2.2","karma-jasmine": "^0.2.2","karma-ng-html2js-preprocessor": "^0.2.1",
我在插件中引用了我的安装.
plugins: [ 'karma-chrome-launcher','karma-jasmine','karma-sinon','karma-ng-html2js-preprocessor' ],
我已经加载了所有文件
files: [ //jquery libaries // angular libraries // Scripts files // source app.js // tests folder and files ]
我的测试开始于Karma
但是,我的指令只是一个空字符串
element.html()
返回“”
我有吟游诗人注射设置
bard.inject( "$compile","$controller","$rootScope",'$templateCache',"haConfig","$q" );
这是我之前的内心
bard.mockService(haConfig,{ getTemplateUrl: '/tst!' }); //bard.mockService(haConfig,{}); console.log('ha config2',haConfig.getTemplateUrl()); var html = angular.element("<div explore-hero></div>"); console.log('htl',haConfig.getTemplateUrl()); scope = $rootScope.$new(); //templateCache element = $compile(html)(scope); //console.log(haConfig.getTemplateUrl(html)); scope.$digest(element); console.log('missing text',haConfig.getTemplateUrl(html)); controller = element.scope(); console.log("element",element);
我不知道为什么我要回一个空字符串.我正在创建html文件,但内部没有任何内容.
所有我都想知道我是否应该在我的开发工具的文件夹中显示templatesCached文件?另外,是否应该在karma.conf.js内的files数组中引用文件
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。