我的应用程序中的每张图片都会收到烦人的 404 警告。我尝试了 stackoverflow 上提供的不同解决方案,但仍然没有成功。我的单元测试已通过,但出现 404 警告。
karma 配置
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/'
},
};
警告
更新
我从 url 中删除了这个 __test,所以现在我得到:
WARN [web-server]: 404: /assets/images/map_WRO_lrg.png ..
我按照 karma 官方建议添加了此代理 http://karma-runner.github.io/0.13/config/files.html :
proxies: {
"/img/": "/base/test/images/"
},
也尝试过这个:
proxies: {
"/img/": "http://localhost:9876/base/test/images/"
},
但同样的警告......
最佳答案
您应该尝试添加代理而不像这样:
代理:{
“/ Assets /”:“/ Assets /”
}
关于javascript - 获取图像 jasmine-Angular 的警告 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39724904/