如何设置代理以使文件在业力中发挥作用

时间:2018-09-06 05:15:37

标签: angular unit-testing karma-jasmine web-frontend

在我的页面中,我需要加载一个json文件,以告知该页面应将请求发送到哪个服务器。 我使用ajax加载json,它在除单元测试之外的任何地方都可以正常工作。 我使用业力,业力无法加载配置,尽管我已经配置了业力karma.conf.js

files: [
  { pattern: '**/*.woff', included: false, watched: false, nocache: false, served: true },
  { pattern: 'images/*.svg', included: false, watched: false, nocache: false, served: true },
  { pattern: 'images/*.png', included: false, watched: false, nocache: false, served: true },
  { pattern: 'images/*.gif', included: false, watched: false, nocache: false, served: true },
  { pattern: 'config/config.json', included: false, watched: false, nocache: false }
],
proxies: {
  '/images/': '/base/images/',
  '/translations/': '/base/translations/',
  '/config.json': '/base/config.json',
}

它在控制台[web-server]: 404: /base/config.json中显示警告

当观察值设置为true时,它可以在我进行一些更改时重新编译测试,因此我认为这可能是代理问题,但我真的不知道它有什么问题。

0 个答案:

没有答案