ts-jest
- Version 29.2.5
- Published
- 328 kB
- 9 dependencies
- MIT license
Install
npm i ts-jest
yarn add ts-jest
pnpm add ts-jest
Overview
A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript
Index
Variables
Functions
- createDefaultEsmLegacyPreset()
- createDefaultEsmPreset()
- createDefaultLegacyPreset()
- createDefaultPreset()
- createJestPreset()
- createJsWithBabelEsmLegacyPreset()
- createJsWithBabelEsmPreset()
- createJsWithBabelLegacyPreset()
- createJsWithBabelPreset()
- createJsWithTsEsmLegacyPreset()
- createJsWithTsEsmPreset()
- createJsWithTsLegacyPreset()
- createJsWithTsPreset()
- parse()
- pathsToModuleNameMapper()
- stringify()
Classes
Interfaces
RawCompilerOptions
- allowArbitraryExtensions
- allowImportingTsExtensions
- allowJs
- allowSyntheticDefaultImports
- allowUmdGlobalAccess
- allowUnreachableCode
- allowUnusedLabels
- alwaysStrict
- assumeChangesOnlyAffectDirectDependencies
- baseUrl
- charset
- checkJs
- composite
- customConditions
- declaration
- declarationDir
- declarationMap
- diagnostics
- disableReferencedProjectLoad
- disableSizeLimit
- disableSolutionSearching
- disableSourceOfProjectReferenceRedirect
- downlevelIteration
- emitBOM
- emitDeclarationOnly
- emitDecoratorMetadata
- esModuleInterop
- exactOptionalPropertyTypes
- experimentalDecorators
- extendedDiagnostics
- fallbackPolling
- forceConsistentCasingInFileNames
- generateCpuProfile
- importHelpers
- importsNotUsedAsValues
- incremental
- inlineSourceMap
- inlineSources
- isolatedModules
- jsx
- jsxFactory
- jsxFragmentFactory
- jsxImportSource
- keyofStringsOnly
- lib
- listEmittedFiles
- listFiles
- listFilesOnly
- mapRoot
- maxNodeModuleJsDepth
- module
- moduleDetection
- moduleResolution
- newLine
- noEmit
- noEmitHelpers
- noEmitOnError
- noErrorTruncation
- noFallthroughCasesInSwitch
- noImplicitAny
- noImplicitOverride
- noImplicitReturns
- noImplicitThis
- noImplicitUseStrict
- noLib
- noPropertyAccessFromIndexSignature
- noResolve
- noStrictGenericChecks
- noUncheckedIndexedAccess
- noUnusedLocals
- noUnusedParameters
- outDir
- outFile
- paths
- plugins
- preserveConstEnums
- preserveSymlinks
- preserveValueImports
- preserveWatchOutput
- pretty
- reactNamespace
- removeComments
- resolveJsonModule
- resolvePackageJsonExports
- resolvePackageJsonImports
- rootDir
- rootDirs
- skipDefaultLibCheck
- skipLibCheck
- sourceMap
- sourceRoot
- strict
- strictBindCallApply
- strictFunctionTypes
- strictNullChecks
- strictPropertyInitialization
- suppressExcessPropertyErrors
- suppressImplicitAnyIndexErrors
- target
- traceResolution
- tsBuildInfoFile
- typeRoots
- types
- useDefineForClassFields
- useUnknownInCatchVariables
- verbatimModuleSyntax
- watch
- watchDirectory
- watchFile
Type Aliases
- BabelConfig
- DefaultEsmLegacyPreset
- DefaultEsmPreset
- DefaultEsmTransformOptions
- DefaultLegacyPreset
- DefaultPreset
- DefaultTransformOptions
- JsWithBabelEsmLegacyPreset
- JsWithBabelEsmPreset
- JsWithBabelEsmTransformOptions
- JsWithBabelLegacyPreset
- JsWithBabelPreset
- JsWithBabelTransformerOptions
- JsWithTsEsmLegacyPreset
- JsWithTsEsmPreset
- JsWithTsEsmTransformOptions
- JsWithTsLegacyPreset
- JsWithTsPreset
- JsWithTsTransformOptions
- StringMap
- TsJestPresets
- TsJestTransformerOptions
- TsJestTransformOptions
- TTypeScript
Variables
variable _default
const _default: { createTransformer(tsJestConfig?: TsJestTransformerOptions): TsJestTransformer;};
variable DECLARATION_TYPE_EXT
const DECLARATION_TYPE_EXT: string;
variable ESM_JS_TRANSFORM_PATTERN
const ESM_JS_TRANSFORM_PATTERN: string;
variable ESM_TS_JS_TRANSFORM_PATTERN
const ESM_TS_JS_TRANSFORM_PATTERN: string;
variable ESM_TS_TRANSFORM_PATTERN
const ESM_TS_TRANSFORM_PATTERN: string;
variable JS_EXT_TO_TREAT_AS_ESM
const JS_EXT_TO_TREAT_AS_ESM: string[];
variable JS_JSX_EXTENSIONS
const JS_JSX_EXTENSIONS: string[];
variable JS_JSX_REGEX
const JS_JSX_REGEX: RegExp;
variable JS_TRANSFORM_PATTERN
const JS_TRANSFORM_PATTERN: string;
variable LINE_FEED
const LINE_FEED: string;
variable rootLogger
let rootLogger: any;
variable TS_EXT_TO_TREAT_AS_ESM
const TS_EXT_TO_TREAT_AS_ESM: string[];
variable TS_JS_TRANSFORM_PATTERN
const TS_JS_TRANSFORM_PATTERN: string;
variable TS_TRANSFORM_PATTERN
const TS_TRANSFORM_PATTERN: string;
variable TS_TSX_REGEX
const TS_TSX_REGEX: RegExp;
Functions
function createDefaultEsmLegacyPreset
createDefaultEsmLegacyPreset: ( tsJestTransformOptions?: DefaultEsmTransformOptions) => DefaultEsmLegacyPreset;
function createDefaultEsmPreset
createDefaultEsmPreset: ( tsJestTransformOptions?: DefaultEsmTransformOptions) => DefaultEsmPreset;
function createDefaultLegacyPreset
createDefaultLegacyPreset: ( tsJestTransformOptions?: DefaultTransformOptions) => DefaultLegacyPreset;
function createDefaultPreset
createDefaultPreset: ( tsJestTransformOptions?: DefaultTransformOptions) => DefaultPreset;
function createJestPreset
createJestPreset: ( legacy?: boolean, allowJs?: boolean, extraOptions?: Config.InitialOptions) => TsJestPresets;
Deprecated
use other functions below instead
function createJsWithBabelEsmLegacyPreset
createJsWithBabelEsmLegacyPreset: ( tsJestTransformOptions?: JsWithBabelEsmTransformOptions) => JsWithBabelEsmLegacyPreset;
function createJsWithBabelEsmPreset
createJsWithBabelEsmPreset: ( tsJestTransformOptions?: JsWithBabelEsmTransformOptions) => JsWithBabelEsmPreset;
function createJsWithBabelLegacyPreset
createJsWithBabelLegacyPreset: ( tsJestTransformOptions?: JsWithBabelTransformerOptions) => JsWithBabelLegacyPreset;
function createJsWithBabelPreset
createJsWithBabelPreset: ( tsJestTransformOptions?: JsWithBabelTransformerOptions) => JsWithBabelPreset;
function createJsWithTsEsmLegacyPreset
createJsWithTsEsmLegacyPreset: ( tsJestTransformOptions?: JsWithTsEsmTransformOptions) => JsWithTsEsmLegacyPreset;
function createJsWithTsEsmPreset
createJsWithTsEsmPreset: ( tsJestTransformOptions?: JsWithTsEsmTransformOptions) => JsWithTsEsmPreset;
function createJsWithTsLegacyPreset
createJsWithTsLegacyPreset: ( tsJestTransformOptions?: JsWithTsTransformOptions) => JsWithTsLegacyPreset;
function createJsWithTsPreset
createJsWithTsPreset: ( tsJestTransformOptions?: JsWithTsTransformOptions) => JsWithTsPreset;
function parse
parse: (input: string) => any;
function pathsToModuleNameMapper
pathsToModuleNameMapper: ( mapping: TsPathMapping, { prefix, useESM }?: { prefix?: string; useESM?: boolean }) => Config.InitialOptions;
function stringify
stringify: (input: unknown) => string;
Classes
class ConfigSet
class ConfigSet {}
constructor
constructor(jestConfig: any, parentLogger?: any);
property cacheSuffix
cacheSuffix: string;
property compilerModule
readonly compilerModule: any;
property cwd
readonly cwd: string;
property isolatedModules
readonly isolatedModules: boolean;
property logger
readonly logger: Logger;
property parentLogger
readonly parentLogger?: any;
property parsedTsConfig
parsedTsConfig: any;
property resolvedTransformers
resolvedTransformers: TsJestAstTransformer;
property rootDir
readonly rootDir: string;
property tsCacheDir
tsCacheDir: string;
property tsJestDigest
readonly tsJestDigest: string;
Use by e2e, don't mark as internal
property useESM
useESM: boolean;
method isTestFile
isTestFile: (fileName: string) => boolean;
method raiseDiagnostics
raiseDiagnostics: ( diagnostics: ts.Diagnostic[], filePath?: string, logger?: Logger) => void;
method resolvePath
resolvePath: ( inputPath: string, { throwIfMissing, nodeResolve, }?: { throwIfMissing?: boolean; nodeResolve?: boolean }) => string;
method shouldReportDiagnostics
shouldReportDiagnostics: (filePath: string) => boolean;
method shouldStringifyContent
shouldStringifyContent: (filePath: string) => boolean;
class JsonableValue
class JsonableValue<V = Record<string, any>> {}
constructor
constructor(value: {});
property serialized
readonly serialized: string;
property value
value: {};
method toString
toString: () => string;
method valueOf
valueOf: () => V;
class TsCompiler
class TsCompiler implements TsCompilerInstance {}
constructor
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
property configSet
readonly configSet: ConfigSet;
property program
program: any;
property runtimeCacheFS
readonly runtimeCacheFS: StringMap;
method getCompiledOutput
getCompiledOutput: ( fileContent: string, fileName: string, options: TsJestCompileOptions) => CompiledOutput;
method getResolvedModules
getResolvedModules: ( fileContent: string, fileName: string, runtimeCacheFS: StringMap) => string[];
class TsJestCompiler
class TsJestCompiler implements CompilerInstance {}
constructor
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
method getCompiledOutput
getCompiledOutput: ( fileContent: string, fileName: string, options: TsJestCompileOptions) => CompiledOutput;
method getResolvedModules
getResolvedModules: ( fileContent: string, fileName: string, runtimeCacheFS: StringMap) => string[];
class TsJestTransformer
class TsJestTransformer implements SyncTransformer<TsJestTransformerOptions> {}
constructor
constructor(transformerOptions?: TsJestGlobalOptions);
method getCacheKey
getCacheKey: ( fileContent: string, filePath: string, transformOptions: TransformOptions<TsJestGlobalOptions>) => string;
Jest uses this to cache the compiled version of a file
See Also
https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
Modifiers
@public
method getCacheKeyAsync
getCacheKeyAsync: ( sourceText: string, sourcePath: string, transformOptions: TransformOptions<TsJestGlobalOptions>) => Promise<string>;
method process
process: ( sourceText: string, sourcePath: string, transformOptions: TransformOptions<TsJestGlobalOptions>) => TransformedSource;
Modifiers
@public
method processAsync
processAsync: ( sourceText: string, sourcePath: string, transformOptions: TransformOptions<TsJestGlobalOptions>) => Promise<TransformedSource>;
Interfaces
interface AstTransformer
interface AstTransformer<T = Record<string, unknown>> {}
interface AstTransformerDesc
interface AstTransformerDesc<T = Record<string, unknown>> {}
interface CompiledOutput
interface CompiledOutput extends TransformedSource {}
property diagnostics
diagnostics?: _ts.Diagnostic[];
interface CompilerInstance
interface CompilerInstance {}
method getCompiledOutput
getCompiledOutput: ( fileContent: string, fileName: string, options: TsJestCompileOptions) => CompiledOutput;
method getResolvedModules
getResolvedModules: ( fileContent: string, fileName: string, runtimeCacheFS: StringMap) => string[];
interface ConfigCustomTransformer
interface ConfigCustomTransformer {}
property after
after?: Array<string | AstTransformer>;
property afterDeclarations
afterDeclarations?: Array<string | AstTransformer>;
property before
before?: Array<string | AstTransformer>;
interface DepGraphInfo
interface DepGraphInfo {}
property fileContent
fileContent: string;
property resolvedModuleNames
resolvedModuleNames: string[];
interface GlobalConfigTsJest
interface GlobalConfigTsJest extends Config.ConfigGlobals {}
For typings in
jest.config.ts
Deprecated
use
JestConfigWithTsJest
instead
property 'ts-jest'
'ts-jest'?: TsJestGlobalOptions;
interface InitialOptionsTsJest
interface InitialOptionsTsJest extends Config.InitialOptions {}
Deprecated
use
JestConfigWithTsJest
instead
property globals
globals?: GlobalConfigTsJest;
interface JestConfigWithTsJest
interface JestConfigWithTsJest extends Omit<Config.InitialOptions, 'transform'> {}
property transform
transform?: { [regex: string]: | 'ts-jest' | 'ts-jest/legacy' | ['ts-jest', TsJestTransformerOptions] | ['ts-jest/legacy', TsJestTransformerOptions] | string | Config.TransformerConfig;};
interface ProjectConfigTsJest
interface ProjectConfigTsJest extends Config.ProjectConfig {}
For transformers which extends
ts-jest
Deprecated
use
JestConfigWithTsJest
instead
property globals
globals: GlobalConfigTsJest;
interface RawCompilerOptions
interface RawCompilerOptions {}
property allowArbitraryExtensions
allowArbitraryExtensions?: boolean | null;
Enable importing files with any extension, provided a declaration file is present.
property allowImportingTsExtensions
allowImportingTsExtensions?: boolean | null;
Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.
property allowJs
allowJs?: boolean | null;
Allow JavaScript files to be a part of your program. Use the
checkJS
option to get errors from these files.
property allowSyntheticDefaultImports
allowSyntheticDefaultImports?: boolean | null;
Allow 'import x from y' when a module doesn't have a default export.
property allowUmdGlobalAccess
allowUmdGlobalAccess?: boolean | null;
Allow accessing UMD globals from modules.
property allowUnreachableCode
allowUnreachableCode?: boolean | null;
Disable error reporting for unreachable code.
property allowUnusedLabels
allowUnusedLabels?: boolean | null;
Disable error reporting for unused labels.
property alwaysStrict
alwaysStrict?: boolean | null;
Ensure 'use strict' is always emitted.
property assumeChangesOnlyAffectDirectDependencies
assumeChangesOnlyAffectDirectDependencies?: boolean | null;
Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it. Requires TypeScript version 3.8 or later.
property baseUrl
baseUrl?: string | null;
Specify the base directory to resolve non-relative module names.
property charset
charset?: string | null;
No longer supported. In early versions, manually set the text encoding for reading files.
property checkJs
checkJs?: boolean | null;
Enable error reporting in type-checked JavaScript files.
property composite
composite?: boolean | null;
Enable constraints that allow a TypeScript project to be used with project references.
property customConditions
customConditions?: Array<string | null> | null;
Conditions to set in addition to the resolver-specific defaults when resolving imports.
property declaration
declaration?: boolean | null;
Generate .d.ts files from TypeScript and JavaScript files in your project.
property declarationDir
declarationDir?: string | null;
Specify the output directory for generated declaration files.
property declarationMap
declarationMap?: boolean | null;
Create sourcemaps for d.ts files.
property diagnostics
diagnostics?: boolean | null;
Output compiler performance information after building.
property disableReferencedProjectLoad
disableReferencedProjectLoad?: boolean | null;
Reduce the number of projects loaded automatically by TypeScript.
property disableSizeLimit
disableSizeLimit?: boolean | null;
Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
property disableSolutionSearching
disableSolutionSearching?: boolean | null;
Opt a project out of multi-project reference checking when editing.
property disableSourceOfProjectReferenceRedirect
disableSourceOfProjectReferenceRedirect?: boolean | null;
Disable preferring source files instead of declaration files when referencing composite projects
property downlevelIteration
downlevelIteration?: boolean | null;
Emit more compliant, but verbose and less performant JavaScript for iteration.
property emitBOM
emitBOM?: boolean | null;
Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
property emitDeclarationOnly
emitDeclarationOnly?: boolean | null;
Only output d.ts files and not JavaScript files.
property emitDecoratorMetadata
emitDecoratorMetadata?: boolean | null;
Emit design-type metadata for decorated declarations in source files.
property esModuleInterop
esModuleInterop?: boolean | null;
Emit additional JavaScript to ease support for importing CommonJS modules. This enables
allowSyntheticDefaultImports
for type compatibility.
property exactOptionalPropertyTypes
exactOptionalPropertyTypes?: boolean | null;
Differentiate between undefined and not present when type checking
property experimentalDecorators
experimentalDecorators?: boolean | null;
Enable experimental support for TC39 stage 2 draft decorators.
property extendedDiagnostics
extendedDiagnostics?: boolean | null;
Output more detailed compiler performance information after building.
property fallbackPolling
fallbackPolling?: | 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'fixedInterval' | 'priorityInterval' | 'dynamicPriority' | 'fixedChunkSize';
Specify the polling strategy to use when the system runs out of or doesn't support native file watchers. Requires TypeScript version 3.8 or later.
property forceConsistentCasingInFileNames
forceConsistentCasingInFileNames?: boolean | null;
Ensure that casing is correct in imports.
property generateCpuProfile
generateCpuProfile?: string | null;
Emit a v8 CPU profile of the compiler run for debugging.
property importHelpers
importHelpers?: boolean | null;
Allow importing helper functions from tslib once per project, instead of including them per-file.
property importsNotUsedAsValues
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
Specify emit/checking behavior for imports that are only used for types.
property incremental
incremental?: boolean | null;
Enable incremental compilation. Requires TypeScript version 3.4 or later.
property inlineSourceMap
inlineSourceMap?: boolean | null;
Include sourcemap files inside the emitted JavaScript.
property inlineSources
inlineSources?: boolean | null;
Include source code in the sourcemaps inside the emitted JavaScript.
property isolatedModules
isolatedModules?: boolean | null;
Ensure that each file can be safely transpiled without relying on other imports.
property jsx
jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
Specify what JSX code is generated.
property jsxFactory
jsxFactory?: string | null;
Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'
property jsxFragmentFactory
jsxFragmentFactory?: string | null;
Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
property jsxImportSource
jsxImportSource?: string | null;
Specify module specifier used to import the JSX factory functions when using
jsx: react-jsx
.
property keyofStringsOnly
keyofStringsOnly?: boolean | null;
Make keyof only return strings instead of string, numbers or symbols. Legacy option.
property lib
lib?: Array< ( | ( | 'ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable' ) | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } ) & ( | (( | ( | 'ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable' ) | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } ) & string) | (( | ( | 'ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable' ) | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } | { [k: string]: unknown; } ) & null) )> | null;
Specify a set of bundled library declaration files that describe the target runtime environment.
property listEmittedFiles
listEmittedFiles?: boolean | null;
Print the names of emitted files after a compilation.
property listFiles
listFiles?: boolean | null;
Print all of the files read during the compilation.
property listFilesOnly
listFilesOnly?: boolean | null;
Print names of files that are part of the compilation and then stop processing.
property mapRoot
mapRoot?: string | null;
Specify the location where debugger should locate map files instead of generated locations.
property maxNodeModuleJsDepth
maxNodeModuleJsDepth?: number | null;
Specify the maximum folder depth used for checking JavaScript files from
node_modules
. Only applicable withallowJs
.
property module
module?: ( | 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') & ( | (( | ( | 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve' ) | { [k: string]: unknown; } ) & string) | (( | ( | 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve' ) | { [k: string]: unknown; } ) & null) );
Specify what module code is generated.
property moduleDetection
moduleDetection?: 'auto' | 'legacy' | 'force';
Specify how TypeScript determine a file as module.
property moduleResolution
moduleResolution?: ( | 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') & ( | (( | ( | 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler' ) | { [k: string]: unknown; } ) & string) | (( | ( | 'Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler' ) | { [k: string]: unknown; } ) & null) );
Specify how TypeScript looks up a file from a given module specifier.
property newLine
newLine?: ('crlf' | 'lf') & ( | (( | ('crlf' | 'lf') | { [k: string]: unknown; } ) & string) | (( | ('crlf' | 'lf') | { [k: string]: unknown; } ) & null) );
Set the newline character for emitting files.
property noEmit
noEmit?: boolean | null;
Disable emitting file from a compilation.
property noEmitHelpers
noEmitHelpers?: boolean | null;
Disable generating custom helper functions like
__extends
in compiled output.
property noEmitOnError
noEmitOnError?: boolean | null;
Disable emitting files if any type checking errors are reported.
property noErrorTruncation
noErrorTruncation?: boolean | null;
Disable truncating types in error messages.
property noFallthroughCasesInSwitch
noFallthroughCasesInSwitch?: boolean | null;
Enable error reporting for fallthrough cases in switch statements.
property noImplicitAny
noImplicitAny?: boolean | null;
Enable error reporting for expressions and declarations with an implied
any
type..
property noImplicitOverride
noImplicitOverride?: boolean | null;
Ensure overriding members in derived classes are marked with an override modifier.
property noImplicitReturns
noImplicitReturns?: boolean | null;
Enable error reporting for codepaths that do not explicitly return in a function.
property noImplicitThis
noImplicitThis?: boolean | null;
Enable error reporting when
this
is given the typeany
.
property noImplicitUseStrict
noImplicitUseStrict?: boolean | null;
Disable adding 'use strict' directives in emitted JavaScript files.
property noLib
noLib?: boolean | null;
Disable including any library files, including the default lib.d.ts.
property noPropertyAccessFromIndexSignature
noPropertyAccessFromIndexSignature?: boolean | null;
Enforces using indexed accessors for keys declared using an indexed type
property noResolve
noResolve?: boolean | null;
Disallow
import
s,require
s or<reference>
s from expanding the number of files TypeScript should add to a project.
property noStrictGenericChecks
noStrictGenericChecks?: boolean | null;
Disable strict checking of generic signatures in function types.
property noUncheckedIndexedAccess
noUncheckedIndexedAccess?: boolean | null;
Add
undefined
to a type when accessed using an index.
property noUnusedLocals
noUnusedLocals?: boolean | null;
Enable error reporting when a local variables aren't read.
property noUnusedParameters
noUnusedParameters?: boolean | null;
Raise an error when a function parameter isn't read
property outDir
outDir?: string | null;
Specify an output folder for all emitted files.
property outFile
outFile?: string | null;
Specify a file that bundles all outputs into one JavaScript file. If
declaration
is true, also designates a file that bundles all .d.ts output.
property paths
paths?: { [k: string]: Array<string | null> | null;} | null;
Specify a set of entries that re-map imports to additional lookup locations.
property plugins
plugins?: Array<{ /** * Plugin name. */ name?: string | null; [k: string]: unknown;} | null> | null;
Specify a list of language service plugins to include.
property preserveConstEnums
preserveConstEnums?: boolean | null;
Disable erasing
const enum
declarations in generated code.
property preserveSymlinks
preserveSymlinks?: boolean | null;
Disable resolving symlinks to their realpath. This correlates to the same flag in node.
property preserveValueImports
preserveValueImports?: boolean | null;
Preserve unused imported values in the JavaScript output that would otherwise be removed
property preserveWatchOutput
preserveWatchOutput?: boolean | null;
Disable wiping the console in watch mode
property pretty
pretty?: boolean | null;
Enable color and formatting in output to make compiler errors easier to read
property reactNamespace
reactNamespace?: string | null;
Specify the object invoked for
createElement
. This only applies when targetingreact
JSX emit.
property removeComments
removeComments?: boolean | null;
Disable emitting comments.
property resolveJsonModule
resolveJsonModule?: boolean | null;
Enable importing .json files
property resolvePackageJsonExports
resolvePackageJsonExports?: boolean | null;
Use the package.json 'exports' field when resolving package imports.
property resolvePackageJsonImports
resolvePackageJsonImports?: boolean | null;
Use the package.json 'imports' field when resolving imports.
property rootDir
rootDir?: string | null;
Specify the root folder within your source files.
property rootDirs
rootDirs?: Array<string | null> | null;
Allow multiple folders to be treated as one when resolving modules.
property skipDefaultLibCheck
skipDefaultLibCheck?: boolean | null;
Skip type checking .d.ts files that are included with TypeScript.
property skipLibCheck
skipLibCheck?: boolean | null;
Skip type checking all .d.ts files.
property sourceMap
sourceMap?: boolean | null;
Create source map files for emitted JavaScript files.
property sourceRoot
sourceRoot?: string | null;
Specify the root path for debuggers to find the reference source code.
property strict
strict?: boolean | null;
Enable all strict type checking options.
property strictBindCallApply
strictBindCallApply?: boolean | null;
Check that the arguments for
bind
,call
, andapply
methods match the original function.
property strictFunctionTypes
strictFunctionTypes?: boolean | null;
When assigning functions, check to ensure parameters and the return values are subtype-compatible.
property strictNullChecks
strictNullChecks?: boolean | null;
When type checking, take into account
null
andundefined
.
property strictPropertyInitialization
strictPropertyInitialization?: boolean | null;
Check for class properties that are declared but not set in the constructor.
property suppressExcessPropertyErrors
suppressExcessPropertyErrors?: boolean | null;
Disable reporting of excess property errors during the creation of object literals.
property suppressImplicitAnyIndexErrors
suppressImplicitAnyIndexErrors?: boolean | null;
Suppress
noImplicitAny
errors when indexing objects that lack index signatures.
property target
target?: ( | 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') & ( | (( | ( | 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext' ) | { [k: string]: unknown; } ) & string) | (( | ( | 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext' ) | { [k: string]: unknown; } ) & null) );
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
property traceResolution
traceResolution?: boolean | null;
Enable tracing of the name resolution process. Requires TypeScript version 2.0 or later.
property tsBuildInfoFile
tsBuildInfoFile?: string | null;
Specify the folder for .tsbuildinfo incremental compilation files.
property typeRoots
typeRoots?: Array<string | null> | null;
Specify multiple folders that act like
./node_modules/@types
.
property types
types?: Array<string | null> | null;
Specify type package names to be included without being referenced in a source file.
property useDefineForClassFields
useDefineForClassFields?: boolean | null;
Emit ECMAScript-standard-compliant class fields.
property useUnknownInCatchVariables
useUnknownInCatchVariables?: boolean | null;
Default catch clause variables as
unknown
instead ofany
.
property verbatimModuleSyntax
verbatimModuleSyntax?: boolean | null;
Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting.
property watch
watch?: boolean | null;
Watch input files.
property watchDirectory
watchDirectory?: | 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling' | 'fixedChunkSizePolling';
Specify the strategy for watching directories under systems that lack recursive file-watching functionality. Requires TypeScript version 3.8 or later.
property watchFile
watchFile?: | 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory' | 'fixedChunkSizePolling';
Specify the strategy for watching individual files. Requires TypeScript version 3.8 or later.
index signature
[k: string]: unknown;
interface TransformOptionsTsJest
interface TransformOptionsTsJest<TransformerConfig = unknown> extends TransformOptions<TransformerConfig> {}
Deprecated
use
JestConfigWithTsJest
instead
property config
config: Config.ProjectConfig;
interface TsCompilerInstance
interface TsCompilerInstance extends CompilerInstance {}
interface TsJestAstTransformer
interface TsJestAstTransformer {}
property after
after: AstTransformerDesc[];
property afterDeclarations
afterDeclarations: AstTransformerDesc[];
property before
before: AstTransformerDesc[];
interface TsJestCompileOptions
interface TsJestCompileOptions {}
property depGraphs
depGraphs: Map<string, DepGraphInfo>;
property supportsStaticESM
supportsStaticESM: boolean;
property watchMode
watchMode: boolean;
interface TsJestGlobalOptions
interface TsJestGlobalOptions {}
Deprecated
use
TsJestTransformerOptions
instead
property astTransformers
astTransformers?: ConfigCustomTransformer;
Custom transformers (mostly used by jest presets)
property babelConfig
babelConfig?: boolean | string | BabelConfig;
Babel config. It can be: -
false
(orundefined
, it's the default): do NOT use babel -true
: use babel using default babelrc file -path/to/.babelrc
: path to a babelrc file ( can be used) -{...}
: an object with inline babel optionsundefined does NOT use babel
property compiler
compiler?: 'typescript' | 'ttypescript' | string;
Compiler to use
'typescript'
property diagnostics
diagnostics?: | boolean | { /** * Enables colorful and pretty output of errors * * @default undefined (enabled) */ pretty?: boolean; /** * List of TypeScript diagnostic error codes to ignore * [here](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json). * * @see https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json * @default [6059,18002,18003] */ ignoreCodes?: number | string | Array<number | string>; /** * If specified, diagnostics of source files which path **matches** will be ignored */ exclude?: string[]; /** * Logs TypeScript errors to stderr instead of throwing exceptions * * @default undefined (disabled) */ warnOnly?: boolean; };
TS diagnostics - less to be reported if
isolatedModules
istrue
. It can be: -true
(orundefined
, it's the default): show all diagnostics -false
: hide diagnostics of all files (kind of useless) -{...}
: an inline object with fine grained settingsundefined shows all diagnostics
property isolatedModules
isolatedModules?: boolean;
Compiles files as isolated modules (disables some features and type-checking)
undefined (disabled)
property stringifyContentPathRegex
stringifyContentPathRegex?: string | RegExp;
Kept for backward compatibility to handle __TRANSFORM_HTML__ Any file which will match this regex will be transpiled as a module exporting the content of the file as a string
property tsconfig
tsconfig?: boolean | string | RawCompilerOptions;
Compiler options. It can be: -
true
(orundefined
, it's the default): use default tsconfig file -false
: do NOT use default config file -path/to/tsconfig.json
: path to a specific tsconfig file ( can be used) -{...}
: an object with inline compiler optionsundefined uses the default tsconfig file
property useESM
useESM?: boolean;
Tell
ts-jest
to transform codes to ESM format. This only works in combination withjest-runtime
ESM optionsupportsStaticESM
true which is passed into Jest transformer
Type Aliases
type BabelConfig
type BabelConfig = _babel.TransformOptions;
Don't mark as internal because it is used in TsJestGlobalOptions which is an exposed type
type DefaultEsmLegacyPreset
type DefaultEsmLegacyPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_TS_TRANSFORM_PATTERN]: [ 'ts-jest/legacy', { useESM: true; } & DefaultEsmTransformOptions ]; };};
type DefaultEsmPreset
type DefaultEsmPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_TS_TRANSFORM_PATTERN]: [ 'ts-jest', { useESM: true; } & DefaultEsmTransformOptions ]; };};
type DefaultEsmTransformOptions
type DefaultEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type DefaultLegacyPreset
type DefaultLegacyPreset = { transform: { [TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', DefaultTransformOptions]; };};
type DefaultPreset
type DefaultPreset = { transform: { [TS_TRANSFORM_PATTERN]: ['ts-jest', DefaultTransformOptions]; };};
type DefaultTransformOptions
type DefaultTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type JsWithBabelEsmLegacyPreset
type JsWithBabelEsmLegacyPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_JS_TRANSFORM_PATTERN]: 'babel-jest'; [ESM_TS_TRANSFORM_PATTERN]: [ 'ts-jest/legacy', { useESM: true; } & JsWithBabelEsmTransformOptions ]; };};
type JsWithBabelEsmPreset
type JsWithBabelEsmPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_JS_TRANSFORM_PATTERN]: 'babel-jest'; [ESM_TS_TRANSFORM_PATTERN]: [ 'ts-jest', { useESM: true; } & JsWithBabelEsmTransformOptions ]; };};
type JsWithBabelEsmTransformOptions
type JsWithBabelEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type JsWithBabelLegacyPreset
type JsWithBabelLegacyPreset = { transform: { [JS_TRANSFORM_PATTERN]: 'babel-jest'; [TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithBabelTransformerOptions]; };};
type JsWithBabelPreset
type JsWithBabelPreset = { transform: { [JS_TRANSFORM_PATTERN]: 'babel-jest'; [TS_TRANSFORM_PATTERN]: ['ts-jest', JsWithBabelTransformerOptions]; };};
type JsWithBabelTransformerOptions
type JsWithBabelTransformerOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type JsWithTsEsmLegacyPreset
type JsWithTsEsmLegacyPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest/legacy', { useESM: true; } & JsWithTsEsmTransformOptions ]; };};
type JsWithTsEsmPreset
type JsWithTsEsmPreset = { extensionsToTreatAsEsm: string[]; transform: { [ESM_TS_JS_TRANSFORM_PATTERN]: [ 'ts-jest', { useESM: true; } & JsWithTsEsmTransformOptions ]; };};
type JsWithTsEsmTransformOptions
type JsWithTsEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type JsWithTsLegacyPreset
type JsWithTsLegacyPreset = { transform: { [TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithTsTransformOptions]; };};
type JsWithTsPreset
type JsWithTsPreset = { transform: { [TS_JS_TRANSFORM_PATTERN]: ['ts-jest', JsWithTsTransformOptions]; };};
type JsWithTsTransformOptions
type JsWithTsTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
type StringMap
type StringMap = Map<string, string>;
type TsJestPresets
type TsJestPresets = Pick< JestConfigWithTsJest, 'extensionsToTreatAsEsm' | 'moduleFileExtensions' | 'transform' | 'testMatch'>;
Deprecated
use other preset types below instead
type TsJestTransformerOptions
type TsJestTransformerOptions = TsJestGlobalOptions;
type TsJestTransformOptions
type TsJestTransformOptions = TransformOptions<TsJestTransformerOptions>;
type TTypeScript
type TTypeScript = typeof _ts;
Package Files (13)
- dist/config/paths-to-module-name-mapper.d.ts
- dist/constants.d.ts
- dist/index.d.ts
- dist/legacy/compiler/ts-compiler.d.ts
- dist/legacy/compiler/ts-jest-compiler.d.ts
- dist/legacy/config/config-set.d.ts
- dist/legacy/ts-jest-transformer.d.ts
- dist/presets/create-jest-preset.d.ts
- dist/raw-compiler-options.d.ts
- dist/types.d.ts
- dist/utils/json.d.ts
- dist/utils/jsonable-value.d.ts
- dist/utils/logger.d.ts
Dependencies (9)
Dev Dependencies (41)
- @commitlint/cli
- @commitlint/config-angular
- @jest/globals
- @jest/transform
- @jest/types
- @types/babel__core
- @types/ejs
- @types/fs-extra
- @types/jest
- @types/js-yaml
- @types/lodash.camelcase
- @types/lodash.memoize
- @types/lodash.set
- @types/micromatch
- @types/node
- @types/semver
- @types/yargs
- @types/yargs-parser
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- babel-jest
- conventional-changelog-cli
- esbuild
- eslint
- eslint-config-prettier
- eslint-plugin-import
- eslint-plugin-jest
- eslint-plugin-jsdoc
- eslint-plugin-prefer-arrow
- eslint-plugin-prettier
- execa
- fs-extra
- glob
- glob-gitignore
- husky
- jest
- js-yaml
- json-schema-to-typescript
- lint-staged
- prettier
- typescript
Peer Dependencies (6)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ts-jest
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ts-jest)
- HTML<a href="https://www.jsdocs.io/package/ts-jest"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6099 ms. - Missing or incorrect documentation? Open an issue for this package.