Skip to content

Commit 2ae255a

Browse files
rafecafacebook-github-bot
authored andcommittedNov 22, 2017
Update jest preprocessors to use the ast from the transformers
Reviewed By: jeanlauliac Differential Revision: D6390677 fbshipit-source-id: e023fc32188c2d601b35d7a2e3f0f6f8af067962
1 parent 7fd5aa8 commit 2ae255a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed
 

‎jest/preprocessor.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const babelRegisterOnly = require('metro-bundler/src/babelRegisterOnly');
2525
* found when Flow v0.54 was deployed. To see the error delete this comment and
2626
* run Flow. */
2727
const createCacheKeyFunction = require('fbjs-scripts/jest/createCacheKeyFunction');
28+
const generate = require('babel-generator').default;
2829

2930
const nodeFiles = RegExp([
3031
'/local-cli/',
@@ -47,7 +48,7 @@ module.exports = {
4748
).code;
4849
}
4950

50-
return transformer.transform({
51+
const {ast} = transformer.transform({
5152
filename: file,
5253
localPath: file,
5354
options: {
@@ -58,7 +59,17 @@ module.exports = {
5859
retainLines: true,
5960
},
6061
src,
61-
}).code;
62+
});
63+
64+
return generate(ast, {
65+
code: true,
66+
comments: false,
67+
compact: false,
68+
filename: file,
69+
retainLines: true,
70+
sourceFileName: file,
71+
sourceMaps: true,
72+
}, src).code;
6273
},
6374

6475
getCacheKey: createCacheKeyFunction([

0 commit comments

Comments
 (0)