-1

I am testing an Angular app and, for specs, I'm supplying a non-existent URL for an image (e.g. /foo1.jpg).

The tests run okay, however, webpack throws a warning:

15 04 2022 06:28:22.123:WARN [web-server]: 404: /_karma_webpack_/foo1.jpg

Is there a way I can either suppress the warning (I get a LOT of them), or better mock an image path?

a11smiles
  • 1,190
  • 1
  • 9
  • 21
  • Add an image to your assets folder and give its URL to your mocks ? –  Apr 15 '22 at 10:33
  • The images are dynamically provided from a webservice. Wouldn't it be bad form to create some random `foo1.jpg` image in my assets folder just for testing? After all, the image isn't being deployed. – a11smiles Apr 15 '22 at 10:35
  • 1
    You can opt it out of the production build with a given config in `angular.json` if need be, but juste the favicon should do the trick I guess ? –  Apr 15 '22 at 10:36
  • Also, you have [this kind of utilitaries online](https://picsum.photos/) –  Apr 15 '22 at 10:38
  • good thought on the favicon.ico. I used that. Thanks! – a11smiles Apr 15 '22 at 10:39
  • Glad to hear that, happy coding ! –  Apr 15 '22 at 10:40

1 Answers1

0

As @temp_user suggested, I simply changed my references to /favicon.ico.

a11smiles
  • 1,190
  • 1
  • 9
  • 21