From e05fb226bfe68cd2eaf572e319a614e63af59c25 Mon Sep 17 00:00:00 2001 From: Shane Krueger Date: Sun, 7 Nov 2021 21:48:04 -0500 Subject: [PATCH 1/2] Ignore imported images when running tests --- jest.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jest.config.js b/jest.config.js index a179e4d..a0bfe47 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,8 @@ module.exports = { ], transform: { '^.+\\.(ts|tsx)$': 'ts-jest', + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': + './config/fileTransformer.js', }, globals: { 'ts-jest': { From 932e5a008baf561f90f712e3dfccdf6603671706 Mon Sep 17 00:00:00 2001 From: Shane Krueger Date: Sun, 7 Nov 2021 21:49:30 -0500 Subject: [PATCH 2/2] Create fileTransformer.js --- config/fileTransformer.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 config/fileTransformer.js diff --git a/config/fileTransformer.js b/config/fileTransformer.js new file mode 100644 index 0000000..39172bc --- /dev/null +++ b/config/fileTransformer.js @@ -0,0 +1,9 @@ +// source: https://jestjs.io/docs/code-transformation#examples + +const path = require('path'); + +module.exports = { + process(src, filename, config, options) { + return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'; + }, +};