Permalink
Browse files

Update jest preprocessors to use the ast from the transformers

Reviewed By: jeanlauliac

Differential Revision: D6390677

fbshipit-source-id: e023fc32188c2d601b35d7a2e3f0f6f8af067962
  • Loading branch information...
rafeca authored and facebook-github-bot committed Nov 22, 2017
1 parent 7fd5aa8 commit 2ae255a6eaf820992bdf19799bb4403f3bbdcd5b
Showing with 13 additions and 2 deletions.
  1. +13 −2 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([

0 comments on commit 2ae255a

Please sign in to comment.