From af3570c6370524681a28a7a44a3d272920203c12 Mon Sep 17 00:00:00 2001 From: dalcib Date: Sun, 9 Dec 2018 20:04:58 -0800 Subject: [PATCH] Make jest react-native preset to use typescript files (#22217) Summary: Metro and react-native now have first-class support to Typescript with Babel 7, but react-native Jest preset needs specific settings to work with .ts and .tsx files. This PR updates react-native Jest preset to use Typescript out of the box. Pull Request resolved: https://github.com/facebook/react-native/pull/22217 Differential Revision: D13396206 Pulled By: cpojer fbshipit-source-id: aa4e4163e555c6b213457755bc13432fa1cddf5e --- jest-preset.json | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jest-preset.json b/jest-preset.json index c7fb437e4..d9c84f84b 100644 --- a/jest-preset.json +++ b/jest-preset.json @@ -7,6 +7,14 @@ "react-native" ] }, + "moduleFileExtensions": [ + "js", + "json", + "jsx", + "node", + "ts", + "tsx" + ], "moduleNameMapper": { "^React$": "/node_modules/react" }, @@ -14,12 +22,16 @@ "/node_modules/react-native/Libraries/react-native/" ], "transform": { - "^.+\\.js$": "babel-jest", + "^.+\\.(js|ts|tsx)$": "babel-jest", "^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$": "/node_modules/react-native/jest/assetFileTransformer.js" }, "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|react-clone-referenced-element)" ], + "testMatch": [ + "**/__tests__/**/*.(js|ts|tsx)", + "**/?(*.)+(spec|test).(js|ts|tsx)" + ], "setupFiles": [ "/node_modules/react-native/jest/setup.js" ],