From 39b72f0ad48d96a39116f6e6911292977c1f091b Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 30 Aug 2017 22:50:28 +0200 Subject: [PATCH 1/3] fix(babel): Handle ignored files in babel v7 In babel v7 `babel-core.transform()` might return null if a file is ignored. This makes babel-jest not throw a TypeError in this case. --- packages/babel-jest/src/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index 56af59058ef8..6ed10e136c12 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -123,7 +123,13 @@ const createTransformer = (options: any) => { ]); } - return babelTransform(src, theseOptions).code; + // babel v7 might return null in the case when the file has been ignored. + const babelResult = babelTransform(src, theseOptions); + if (!babelResult) { + return src; + } + + return babelResult.code; }, }; }; From 0fc86f98e78bbd503f3dbcd2e8eb2514ba8bfefd Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 30 Aug 2017 22:58:07 +0200 Subject: [PATCH 2/3] style: Remove trailing spaces --- packages/babel-jest/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index 6ed10e136c12..79efd359fcd5 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -128,7 +128,7 @@ const createTransformer = (options: any) => { if (!babelResult) { return src; } - + return babelResult.code; }, }; From 7500fe360b9196aeec336e8b2e152b91dcff5281 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Thu, 31 Aug 2017 09:22:58 +0100 Subject: [PATCH 3/3] Update index.js --- packages/babel-jest/src/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/babel-jest/src/index.js b/packages/babel-jest/src/index.js index 79efd359fcd5..b2306177b9ae 100644 --- a/packages/babel-jest/src/index.js +++ b/packages/babel-jest/src/index.js @@ -124,12 +124,8 @@ const createTransformer = (options: any) => { } // babel v7 might return null in the case when the file has been ignored. - const babelResult = babelTransform(src, theseOptions); - if (!babelResult) { - return src; - } - - return babelResult.code; + const transformResult = babelTransform(src, theseOptions); + return transformResult ? transformResult.code : src; }, }; };