噶0.12.9,单元测试,因果报应-NG-html2js- preprocessor [英] Karma 0.12.9, unit tests, karma-ng-html2js-preprocessor

查看:214
本文介绍了噶0.12.9,单元测试,因果报应-NG-html2js- preprocessor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道是什么问题...

No idea what the problem is...

karma.conf.js

karma.conf.js

  files: [
  // TEMPLATES
  'app/scripts/directives/views/profile_picture.html',

  preprocessors : {
      // generate js files from html templates
      'app/scripts/directives/views/profile_picture.html': 'ng-html2js'
  },

  ngHtml2JsPreprocessor: {
      stripPrefix: 'app/',
      // setting this option will create only a single module that contains templates
      // from all the files, so you can load them all with module('templates')
      moduleName: 'templates'
  },

然后在测试我使用的:

Then in the test I use:

beforeEach(module('templates'));

我的指令templateUrl如下:

My templateUrl in directive looks like:

templateUrl: 'scripts/directives/views/profile_picture.html',

获得

Error: Unexpected request: GET scripts/directives/views/profile_picture.html

任何想法请这可能是不对的或建议检查什么?

Any idea please what could be wrong with this or suggestion what to check?

推荐答案

我有一种同样的问题。要确保你有确切的文件匹配。打开谷歌浏览器控制台,并检查文件路径是完全一样的。

I had kind of the same problem. Be sure you have the exact file match. Open the Google chrome console and check the file path is exactly the same.

在上面为例,我不得不在ngHtml2Js preprocessor.strip preFIX添加一个/的字符串,它的工作。

In the upper exemple, I had to add a "/" string in ngHtml2JsPreprocessor.stripPrefix and it worked.

这篇关于噶0.12.9,单元测试,因果报应-NG-html2js- preprocessor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆