-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: big refactor + fixes (mainly cache key + coverage)
- Loading branch information
Showing
27 changed files
with
299 additions
and
166 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// structure of this file heavilly inspired on: | ||
// https://github.com/facebook/jest/blob/master/packages/babel-jest/src/index.js | ||
|
||
import jestPreset from 'babel-preset-jest'; | ||
import getCacheKeyForArgs from './utils/get-cache-key'; | ||
import { TsJestContext, JestCacheKeyArguments } from './types'; | ||
import preprocess from './preprocess'; | ||
|
||
const createTransformer = (options?: any): jest.Transformer => { | ||
const cache = Object.create(null); | ||
|
||
options = Object.assign({}, options, { | ||
compact: false, | ||
plugins: (options && options.plugins) || [], | ||
presets: ((options && options.presets) || []).concat([jestPreset]), | ||
sourceMaps: 'both', | ||
}); | ||
delete options.cacheDirectory; | ||
delete options.filename; | ||
|
||
const context: TsJestContext = { cache, options }; | ||
|
||
const getCacheKey = (...args: any[]) => | ||
getCacheKeyForArgs(args as JestCacheKeyArguments, context); | ||
|
||
return { | ||
canInstrument: true, | ||
getCacheKey, | ||
process: preprocess, | ||
createTransformer: undefined as any, | ||
}; | ||
}; | ||
|
||
export default createTransformer(); | ||
export { createTransformer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { readFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
|
||
export const BABELRC_FILENAME = '.babelrc'; | ||
export const BABELRC_JS_FILENAME = '.babelrc.js'; | ||
export const BABEL_CONFIG_KEY = 'babel'; | ||
export const TSCONFIG_FILENAME = 'tsconfig.json'; | ||
export const TSCONFIG_GLOBALS_KEY = 'ts-jest'; | ||
export const PACKAGE_JSON = 'package.json'; | ||
export const MY_PACKAGE_CONTENT = readFileSync( | ||
resolve(__dirname, '..', '..', PACKAGE_JSON), | ||
); |
Oops, something went wrong.