-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ng test gives 404 from assets files #2803
Comments
It's a bug, will fix. |
Same issue here. Observation:The path is going from the port where karma is running. The generated path is something like Analysis:This was happening even though the path of the image bin the component was relative to the component file, which means that the path translation is working fine. It's serving the files that is the issue. Question:Is it possible to serve assets in the same host:part as karma is running? Seems like the way to go (ignoring |
Hello, is there a workaround for this until the bug is fixed? |
+1 |
Yes, there is a workaround! In the karma configuration var angularCliConfig = require('./angular-cli.json');
var files = [
{ pattern: './src/test.ts', watched: false },
];
var proxies = {};
var assets = angularCliConfig.apps[0].assets;
for (var i = 0; i < assets.length; i++) {
var asset = assets[i];
proxies['/' + asset] = '/base/src/' + asset;
files.push({
pattern: './src/' + asset,
included: false,
served: true,
watched: true,
});
} Then set the module.exports = function (config) {
config.set({
...
files: files,
proxies: proxies,
...
});
}; I was looking at @filipesilva's PR #3543 and learned from it that Angular CLI modifies the karma config internally as well, which means that it might be possible to fix this issue using the the snippet I posted now injected by the CLI just like the other PR, but I haven't had time to look at it yet. Maybe next week. |
This still doesn't work. |
@megamindbrian this is a scenario we test for and as far as I can tell works. Can you open a new issue with a reproduction of what you are experiencing? |
This is happening for me in Angular 8.1. |
@filipesilva
|
thank you, it's work |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Linux Ubuntu 16.04
Versions.
angular-cli: 1.0.0-beta.17
node: 6.7.0
os: linux x64
Repro steps.
My 'About' component uses images from assets, and
ng test
shows me following warnings;The text was updated successfully, but these errors were encountered: