diff --git a/jest/preprocessor.js b/jest/preprocessor.js index 3734c48c4..b489cead7 100644 --- a/jest/preprocessor.js +++ b/jest/preprocessor.js @@ -25,6 +25,7 @@ const babelRegisterOnly = require('metro-bundler/src/babelRegisterOnly'); * found when Flow v0.54 was deployed. To see the error delete this comment and * run Flow. */ const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction'); +const generate = require('babel-generator').default; const nodeFiles = RegExp([ '/local-cli/', @@ -47,7 +48,7 @@ module.exports = { ).code; } - return transformer.transform({ + const {ast} = transformer.transform({ filename: file, localPath: file, options: { @@ -58,7 +59,17 @@ module.exports = { retainLines: true, }, src, - }).code; + }); + + return generate(ast, { + code: true, + comments: false, + compact: false, + filename: file, + retainLines: true, + sourceFileName: file, + sourceMaps: true, + }, src).code; }, getCacheKey: createCacheKeyFunction([