From 80d2c445807a892ca7bae0b4b7e65e2551771338 Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 6 Sep 2018 18:17:59 -0700 Subject: [PATCH] [jest/ts-jest] update ts-jest wrapper --- src/dev/jest/ts_transform.ts | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/dev/jest/ts_transform.ts b/src/dev/jest/ts_transform.ts index 60f0b11ec94a41..ed366bcd091a0b 100644 --- a/src/dev/jest/ts_transform.ts +++ b/src/dev/jest/ts_transform.ts @@ -17,8 +17,7 @@ * under the License. */ -import { getCacheKey, install, process } from 'ts-jest'; -import { JestConfig, TransformOptions } from 'ts-jest/dist/jest-types'; +import TsJest from 'ts-jest'; import { getTsProjectForAbsolutePath } from '../typescript'; @@ -26,11 +25,11 @@ const DEFAULT_TS_CONFIG_PATH = require.resolve('../../../tsconfig.json'); const DEFAULT_BROWSER_TS_CONFIG_PATH = require.resolve('../../../tsconfig.browser.json'); function extendJestConfigJSON(jestConfigJSON: string, filePath: string) { - const jestConfig = JSON.parse(jestConfigJSON) as JestConfig; + const jestConfig = JSON.parse(jestConfigJSON) as jest.ProjectConfig; return JSON.stringify(extendJestConfig(jestConfig, filePath)); } -function extendJestConfig(jestConfig: JestConfig, filePath: string) { +function extendJestConfig(jestConfig: jest.ProjectConfig, filePath: string) { let tsConfigFile = getTsProjectForAbsolutePath(filePath).tsConfigPath; // swap ts config file for jest tests @@ -51,25 +50,25 @@ function extendJestConfig(jestConfig: JestConfig, filePath: string) { } module.exports = { + canInstrument: true, + process( src: string, - filePath: string, - jestConfig: JestConfig, - transformOptions: TransformOptions + filePath: jest.Path, + jestConfig: jest.ProjectConfig, + transformOptions: jest.TransformOptions ) { const extendedConfig = extendJestConfig(jestConfig, filePath); - return process(src, filePath, extendedConfig, transformOptions); + return TsJest.process(src, filePath, extendedConfig, transformOptions); }, getCacheKey( src: string, filePath: string, jestConfigJSON: string, - transformOptions: TransformOptions + transformOptions: jest.TransformOptions ) { const extendedConfigJSON = extendJestConfigJSON(jestConfigJSON, filePath); - return getCacheKey(src, filePath, extendedConfigJSON, transformOptions); + return TsJest.getCacheKey!(src, filePath, extendedConfigJSON, transformOptions); }, - - install, };