From bc61db84071d4c53cc128e13ba24533f467eb514 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Mon, 3 Feb 2020 17:50:11 -0500 Subject: [PATCH] (feat): support JS & JSX files in tsdx test - JS & JSX are already supported in tsdx build, so this is just adding some better parity in tsdx test - more JS & JSX support also means better support for gradual TS migrations - JS + JSX spec files should also be ran, not just TS + TSX - run them with babel-jest, which is jest's default - changing transform meant babel-jest wasn't run on them anymore - notably, TSDX itself has tests written in JS, so TSDX would need this to dogfood itself - also get coverage from JS + JSX files too --- src/createJestConfig.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/createJestConfig.ts b/src/createJestConfig.ts index 2a05fd78c..9a10921df 100644 --- a/src/createJestConfig.ts +++ b/src/createJestConfig.ts @@ -5,11 +5,12 @@ export function createJestConfig( const config = { transform: { '.(ts|tsx)': require.resolve('ts-jest/dist'), + '.(js|jsx)': require.resolve('babel-jest'), // jest's default }, transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], - collectCoverageFrom: ['src/**/*.{ts,tsx}'], - testMatch: ['/**/*.(spec|test).{ts,tsx}'], + collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}'], + testMatch: ['/**/*.(spec|test).{ts,tsx,js,jsx}'], testURL: 'http://localhost', rootDir, watchPlugins: [