Reputation: 1467
In my angular Application , I have a page where i load bunch of images.
All those images comes from a library. So when ever I run my spec test I get an error
404: /_karmawebpack_//assets/images/my_image.svg
We use karma-jasmine for testing and our library is packaged using karma-webpack.
The scope is only spec test - I can ignore the images being rendered in spec test.
Is there a way I can mock all such url and return a dummy url instead of that, as per shown below
/_karmawebpack_//assets/images/* --> .//favicon.ico
I tried few things using router - but it didn't help much
Upvotes: 0
Views: 360
Reputation: 1467
This might help someone
After trying out multiple combination below karma config change worked for me
It needs to find the path of the resources in the component - so a proxy config will be needed for it
proxies: {
"//asset/images" : "node_modules/@my_module/asset/images/"
}
so the paths here are
**//asset/images** - is the path where i am exporting the images in my component
**node_modules/@my_module/asset/images/** - is the path in current project where i see images under the node_module
After adding this - it did not complain about missing images .
Upvotes: 0