From 951031b5b0d15716835f8b5c66927dac6bbaf823 Mon Sep 17 00:00:00 2001 From: Geraint White Date: Wed, 4 May 2022 12:10:57 +0100 Subject: [PATCH] fix(jest): make assetFileTransformer return object Fixes #33751 Relates to #33576 --- jest/assetFileTransformer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jest/assetFileTransformer.js b/jest/assetFileTransformer.js index b73579601cea47..2e131c58923b27 100644 --- a/jest/assetFileTransformer.js +++ b/jest/assetFileTransformer.js @@ -20,12 +20,13 @@ module.exports = { // the correct images are loaded for components. Essentially // require('img1.png') becomes `Object { "testUri": 'path/to/img1.png' }` in // the Jest snapshot. - process: (_, filename) => - `module.exports = { + process: (_, filename) => ({ + code: `module.exports = { testUri: ${JSON.stringify( path.relative(__dirname, filename).replace(/\\/g, '/'), )} };`, + }), getCacheKey: createCacheKeyFunction([__filename]), };