There should be a way to specify karma that a specific content should be served from a specified path. Right now, the only (very hacky) way to do this is
files = [
{pattern: 'images/*.png', included: false, served: true}
];
proxies = {
'/images': 'http://localhost:9876/base/images'
};
That has the big issue that, when the configuration is run, we cannot be positive that karma will run at port 9876 or another port
I do this (using another webserver) to serve my images and to avoid 404 errors. Is this related to these issues ?
https://github.com/karma-runner/karma/issues/893
https://github.com/karma-runner/karma/issues/864
@glepretre Even when having a second web server would somehow fix this, I was thinking that being able to do
proxies = {
'/images': 'file:///somepath/'
};
would be simple enough to solve the issue here.
I view this issue as unrelated to #893 #864 maybe I am not being able to see the connection
I tried to do :
proxies: {
'/img/': '/base/app/img/'
},
but I got :
Error: options.host and options.port or options.target are required.
I think it depends on the tests but mine pass anyway with this error
@glepretre I think I like your suggestion the best, this should work:
proxies: {
'/img/': '/base/app/img/'
},
We just need to fix https://github.com/karma-runner/karma/blob/master/lib/middleware/proxy.js#L37-L42 - if no host/port is defined, use the Karma ones (proxy to Karma itself).
Anybody willing to send a PR for this?
I have tried above fix for karma-warnings. But it was not fixed for me. Could you any one provide me an right solution to the clear the WARN web- server in karma
I've also encountered this issue,
can't I have fake images URL that doesn't exists when I run the tests?
None of those answers solved this annoying 404 warn.
I've this setup in my karma.conf.js:
files: [
{pattern: 'src/main/webapp/assets/images/**/*.png', included: false, served: true},
'src/main/webapp/assets/scripts/vendor/*.js',
'src/main/webapp/assets/scripts/dist/*.js',
'src/main/webapp/assets/bower_components/angular-mocks/angular-mocks.js',
'src/main/webapp/assets/partials/**/*.html',
'src/test/javascript/spec_helper.js',
'src/test/javascript/**/*.js',
],
exclude: [],
.
.
.
proxies: {
'/assets/images/diagnostico-assinador/': '/base/',
'/assets/images/prioridade/': '/base/'
}
with proxies setup I got this warn:
WARN [web-server]: 404: /base/image.png
without proxies setup I got this warn:
WARN [web-server]: 404: /assets/images/diagnostico-assinador/image.png
WARN [web-server]: 404: /assets/images/prioridade/image.png
Most helpful comment
None of those answers solved this annoying 404 warn.
I've this setup in my karma.conf.js:
with proxies setup I got this warn:
WARN [web-server]: 404: /base/image.pngwithout proxies setup I got this warn: