在我正在测试的代码中,我正在创建一个图像,例如:
const image = new Image();
image.addEventListener("load", () => {});
image.addEventListener("error", () => {});
image.src = "hello.png"
当我在浏览器中运行时,我让 webpack 将该图像复制到 dist 目录,它工作正常。开玩笑,但是我得到了错误Error: Could not load img: "http://localhost/hello.png"
。
关于如何在 Jest 中“提供”这样的静态图像的任何指导?相对于我的测试文件,图像应位于何处?
(注意我testEnvironmentOptions: { resources: 'usable' }
在开玩笑的配置中添加了)