From 5633bac446069a5cb7c0521548d5ceb66725adbc Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 1 Oct 2018 14:17:33 +0100 Subject: [PATCH 1/2] Format SVG React snapshots as tag with props --- packages/react-scripts/config/jest/fileTransform.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/jest/fileTransform.js b/packages/react-scripts/config/jest/fileTransform.js index b5aa17e0f7b..14fc217e2e5 100644 --- a/packages/react-scripts/config/jest/fileTransform.js +++ b/packages/react-scripts/config/jest/fileTransform.js @@ -21,7 +21,18 @@ module.exports = { return `module.exports = { __esModule: true, default: ${assetFilename}, - ReactComponent: () => ${assetFilename}, + ReactComponent: (props) => ({ + $$typeof: Symbol.for('react.element'), + type: 'svg', + ref: null, + key: null, + props: Object.assign({}, props, { + children: '/* ${assetFilename.slice( + 1, + assetFilename.length - 1 + )} */' + }) + }), };`; } From 2a2aafa0848905ec6cdfa8932b67925e7f86407d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 1 Oct 2018 14:30:35 +0100 Subject: [PATCH 2/2] Keep output simpler --- packages/react-scripts/config/jest/fileTransform.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/react-scripts/config/jest/fileTransform.js b/packages/react-scripts/config/jest/fileTransform.js index 14fc217e2e5..f442f0bbd86 100644 --- a/packages/react-scripts/config/jest/fileTransform.js +++ b/packages/react-scripts/config/jest/fileTransform.js @@ -27,10 +27,7 @@ module.exports = { ref: null, key: null, props: Object.assign({}, props, { - children: '/* ${assetFilename.slice( - 1, - assetFilename.length - 1 - )} */' + children: ${assetFilename} }) }), };`;