In my code that's being tested I'm creating an image like:
const image = new Image();
image.addEventListener("load", () => {});
image.addEventListener("error", () => {});
image.src = "hello.png"
When I run in the browser I have webpack copy that image to the dist directory and it works fine. In jest however I get the error Error: Could not load img: "http://localhost/hello.png"
.
Any guidance on how to "serve" a static image like this in Jest? Where should the image be located in relation to my test file?
(note I've added testEnvironmentOptions: { resources: 'usable' }
in the jest config)