获取图像警告404 jasmine-angular

时间:2016-09-27 12:38:19

标签: javascript angularjs unit-testing karma-jasmine

对于我的应用中的每张图片,我都会收到恼人的404警告。我尝试了在stackoverflow上提供的不同解决方案,但仍然没有成功。我的单元测试正在通过,但有404警告。

karma config

var baseDir = 'client';

module.exports = {

  //This is the list of file patterns to load into the browser during testing.
  files: [
    ......
    baseDir + '/src/app/app.js',
    baseDir + '/test/unit/**/*.spec.js',
    {
      pattern: baseDir + '/assets/**/*.json',
      watched: true,
      served: true,
      included: false
    },
    {
      pattern: baseDir + '/assets/images/**/*.png',
      watched: false,
      included: false,
      served: true
    }
  ],

  proxies :  {
  '/images/': '/base/images/'
  },
};

警告

Screenshot of Warning

结构 Screenshot of the structure of the App

更新

我从网址中删除了这个__test,现在我得到了:

WARN [web-server]: 404: /assets/images/map_WRO_lrg.png ..

我通过业力官方建议http://karma-runner.github.io/0.13/config/files.html添加了此代理:

  proxies: {
    "/img/": "/base/test/images/"
  },

并尝试过这个:

proxies: {
  "/img/": "http://localhost:9876/base/test/images/"
},

但同样的警告......

1 个答案:

答案 0 :(得分:1)

你应该尝试添加代理而不是这样:

proxies: { "/assets/": "/assets/" }