From 99f146e54b5a9ef7be707ada566cc53e342f8034 Mon Sep 17 00:00:00 2001 From: Aleksandra Sikora Date: Fri, 1 Oct 2021 08:25:48 +0200 Subject: [PATCH] jest-preset: handle static assets for next/image (#2763) (patch) --- packages/blitz/jest-preset.js | 3 ++- packages/blitz/jest-preset/image-mock.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/blitz/jest-preset/image-mock.js diff --git a/packages/blitz/jest-preset.js b/packages/blitz/jest-preset.js index e5514952ca..2f8982e8ca 100644 --- a/packages/blitz/jest-preset.js +++ b/packages/blitz/jest-preset.js @@ -32,10 +32,11 @@ const common = { (tsConfig && tsConfig.compilerOptions && tsConfig.compilerOptions.paths) || {}, ), "\\.(css|less|sass|scss)$": path.resolve(__dirname, "./jest-preset/identity-obj-proxy.js"), - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": path.resolve( + "\\.(eot|otf|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": path.resolve( __dirname, "./jest-preset/file-mock.js", ), + "\\.(jpg|jpeg|png|gif|webp|ico)$": path.resolve(__dirname, "./jest-preset/image-mock.js"), }, watchPlugins: ["jest-watch-typeahead/filename", "jest-watch-typeahead/testname"], // Coverage output diff --git a/packages/blitz/jest-preset/image-mock.js b/packages/blitz/jest-preset/image-mock.js new file mode 100644 index 0000000000..b3ff2e3761 --- /dev/null +++ b/packages/blitz/jest-preset/image-mock.js @@ -0,0 +1,5 @@ +module.exports = { + src: "/public/test.png", + width: 100, + height: 100, +}