Skip to content

Commit b5ff26b

Browse files
geraintwhitefacebook-github-bot
authored andcommitted
fix(jest): make assetFileTransformer return an object (#33756)
Summary: Fixes #33751 Relates to #33576 Jest 28 removed support for returning a string in the process method of a transformer (https://jestjs.io/docs/upgrading-to-jest28#transformer). This PR changes assetFileTransformer to return an object instead of a string. ## Changelog [Internal] [Fixed] - Return object from assetFileTransformer Pull Request resolved: #33756 Test Plan: Tests pass with Jest 28 when this change is made. Reviewed By: cipolleschi Differential Revision: D37242038 Pulled By: cortinico fbshipit-source-id: d8a5054f5378183f644cd1458785084b26782193
1 parent ea29ae1 commit b5ff26b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

jest/assetFileTransformer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ module.exports = {
2020
// the correct images are loaded for components. Essentially
2121
// require('img1.png') becomes `Object { "testUri": 'path/to/img1.png' }` in
2222
// the Jest snapshot.
23-
process: (_, filename) =>
24-
`module.exports = {
23+
process: (_, filename) => ({
24+
code: `module.exports = {
2525
testUri:
2626
${JSON.stringify(
2727
path.relative(__dirname, filename).replace(/\\/g, '/'),
2828
)}
2929
};`,
30+
}),
3031
getCacheKey: createCacheKeyFunction([__filename]),
3132
};

0 commit comments

Comments
 (0)