ts-jest 26.5.1 → 26.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.ts-jest-digest CHANGED
@@ -1 +1 @@
1
- ce4f21820adc1fe82ffa3a6379b75d5e66b7b8f1
1
+ f76f642c9fd8b73dc7283c31e47a0605a2211608
package/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## [26.5.5](https://github.com/kulshekhar/ts-jest/compare/v26.5.4...v26.5.5) (2021-04-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **compiler:** return file content on emitSkipped for non ts/tsx files ([#2515](https://github.com/kulshekhar/ts-jest/issues/2515)) ([0320fb3](https://github.com/kulshekhar/ts-jest/commit/0320fb3ac22056aafe4d7ae966eab84dbf23fda9)), closes [#2513](https://github.com/kulshekhar/ts-jest/issues/2513)
7
+
8
+
9
+
10
+ ## [26.5.4](https://github.com/kulshekhar/ts-jest/compare/v26.5.3...v26.5.4) (2021-03-17)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **compiler:** initialize compiler with `.ts`/`.tsx`/`.d.ts` files only ([#2457](https://github.com/kulshekhar/ts-jest/issues/2457)) ([1dc731a](https://github.com/kulshekhar/ts-jest/commit/1dc731a5faf7cda59db1cc642eb99fae973b1246)), closes [#2445](https://github.com/kulshekhar/ts-jest/issues/2445)
16
+
17
+
18
+
19
+ ## [26.5.3](https://github.com/kulshekhar/ts-jest/compare/v26.5.2...v26.5.3) (2021-03-03)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **config:** create fallback jest config when jest config is undefined ([#2421](https://github.com/kulshekhar/ts-jest/issues/2421)) ([0fb6b45](https://github.com/kulshekhar/ts-jest/commit/0fb6b45e7dc3dd7588d27f09ac9a8849dff470cb)), closes [#2085](https://github.com/kulshekhar/ts-jest/issues/2085)
25
+ * remove `@types/jest` from direct dep ([#2416](https://github.com/kulshekhar/ts-jest/issues/2416)) ([060302e](https://github.com/kulshekhar/ts-jest/commit/060302ed1eb8708df0acd7ab1d613ff06fc08cf3)), closes [#2406](https://github.com/kulshekhar/ts-jest/issues/2406) [#2411](https://github.com/kulshekhar/ts-jest/issues/2411)
26
+ * **compiler:** return original file content on emit skip ([#2408](https://github.com/kulshekhar/ts-jest/issues/2408)) ([cfba8f4](https://github.com/kulshekhar/ts-jest/commit/cfba8f423dd59536d8b1e1374ef2b20bff2ed857)), closes [#2407](https://github.com/kulshekhar/ts-jest/issues/2407)
27
+
28
+
29
+
30
+ ## [26.5.2](https://github.com/kulshekhar/ts-jest/compare/v26.5.1...v26.5.2) (2021-02-21)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **compiler:** exclude files in `outDir` from compiler source files ([#2376](https://github.com/kulshekhar/ts-jest/issues/2376)) ([9034677](https://github.com/kulshekhar/ts-jest/commit/9034677f9ce0968339d3d942a70e888996fac532)), closes [#2350](https://github.com/kulshekhar/ts-jest/issues/2350) [#2374](https://github.com/kulshekhar/ts-jest/issues/2374)
36
+ * **config:** define `matchTestFilePath` before `setupTsJestCfg` ([#2373](https://github.com/kulshekhar/ts-jest/issues/2373)) ([c427fea](https://github.com/kulshekhar/ts-jest/commit/c427fea48a24b5ce6e8b9260d3c322583b062a77)), closes [#2371](https://github.com/kulshekhar/ts-jest/issues/2371)
37
+ * **config:** improve emit skipped error message and ensure `outDir` always `TS_JEST_OUT_DIR` ([#2357](https://github.com/kulshekhar/ts-jest/issues/2357)) ([f2808bb](https://github.com/kulshekhar/ts-jest/commit/f2808bb0b15231c67ccb9a97ed606741213c03e6))
38
+ * **typings:** set correct typing for `tsconfig`/`tsConfig` option ([#2377](https://github.com/kulshekhar/ts-jest/issues/2377)) ([d4f6aff](https://github.com/kulshekhar/ts-jest/commit/d4f6aff3f181761bf25c64ff1a97dd19a69196f9)), closes [#2368](https://github.com/kulshekhar/ts-jest/issues/2368)
39
+
40
+
41
+
1
42
  ## [26.5.1](https://github.com/kulshekhar/ts-jest/compare/v26.5.0...v26.5.1) (2021-02-09)
2
43
 
3
44
 
@@ -113,7 +113,7 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
113
113
  catch (e) { }
114
114
  }
115
115
  configs.parsedTsConfig.fileNames
116
- .filter(function (fileName) { return !configs.isTestFile(fileName); })
116
+ .filter(function (fileName) { return constants_1.TS_TSX_REGEX.test(path_1.extname(fileName)) && !configs.isTestFile(fileName); })
117
117
  .forEach(function (fileName) {
118
118
  memoryCache.files.set(fileName, {
119
119
  version: 0,
@@ -266,7 +266,13 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
266
266
  }
267
267
  }
268
268
  if (output.emitSkipped) {
269
- throw new TypeError(path_1.relative(cwd, fileName) + ": Emit skipped for language service");
269
+ if (constants_1.TS_TSX_REGEX.test(fileName)) {
270
+ throw new Error(messages_1.interpolate("Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}", { file: fileName }));
271
+ }
272
+ else {
273
+ logger.warn(messages_1.interpolate("Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`", { file: fileName }));
274
+ return [code, '{}'];
275
+ }
270
276
  }
271
277
  if (!output.outputFiles.length) {
272
278
  throw new TypeError(messages_1.interpolate("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`.", {
@@ -2,8 +2,8 @@ import type { Config } from '@jest/types';
2
2
  import { Logger } from 'bs-logger';
3
3
  import { CompilerOptions, CustomTransformers, Diagnostic, ParsedCommandLine } from 'typescript';
4
4
  import type { TTypeScript } from '../types';
5
+ import type { RawCompilerOptions } from '../tsconfig-raw';
5
6
  export declare class ConfigSet {
6
- private readonly jestConfig;
7
7
  private readonly parentLogger?;
8
8
  readonly logger: Logger;
9
9
  readonly compilerModule: TTypeScript;
@@ -14,8 +14,8 @@ export declare class ConfigSet {
14
14
  customTransformers: CustomTransformers;
15
15
  readonly rootDir: string;
16
16
  protected _overriddenCompilerOptions: Partial<CompilerOptions>;
17
- constructor(jestConfig: Config.ProjectConfig, parentLogger?: Logger | undefined);
18
- protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): Record<string, any>;
17
+ constructor(jestConfig: Config.ProjectConfig | undefined, parentLogger?: Logger | undefined);
18
+ protected _resolveTsConfig(compilerOptions?: RawCompilerOptions, resolvedConfigFile?: string): Record<string, any>;
19
19
  get tsJestDigest(): string;
20
20
  isTestFile(fileName: string): boolean;
21
21
  shouldStringifyContent(filePath: string): boolean;
@@ -119,7 +119,6 @@ var ConfigSet = (function () {
119
119
  function ConfigSet(jestConfig, parentLogger) {
120
120
  var _a, _b;
121
121
  var _c, _d, _e, _f;
122
- this.jestConfig = jestConfig;
123
122
  this.parentLogger = parentLogger;
124
123
  this.customTransformers = Object.create(null);
125
124
  this._overriddenCompilerOptions = {
@@ -141,16 +140,14 @@ var ConfigSet = (function () {
141
140
  this.logger = this.parentLogger
142
141
  ? this.parentLogger.child((_a = {}, _a[bs_logger_1.LogContexts.namespace] = 'config', _a))
143
142
  : logger_1.rootLogger.child({ namespace: 'config' });
144
- this.cwd = path_1.normalize((_c = this.jestConfig.cwd) !== null && _c !== void 0 ? _c : process.cwd());
145
- this.rootDir = path_1.normalize((_d = this.jestConfig.rootDir) !== null && _d !== void 0 ? _d : this.cwd);
146
- var tsJestCfg = this.jestConfig.globals && this.jestConfig.globals['ts-jest'];
143
+ this._backportJestCfg(jestConfig !== null && jestConfig !== void 0 ? jestConfig : Object.create(null));
144
+ this.cwd = path_1.normalize((_c = this._jestCfg.cwd) !== null && _c !== void 0 ? _c : process.cwd());
145
+ this.rootDir = path_1.normalize((_d = this._jestCfg.rootDir) !== null && _d !== void 0 ? _d : this.cwd);
146
+ var tsJestCfg = this._jestCfg.globals && this._jestCfg.globals['ts-jest'];
147
147
  var options = tsJestCfg !== null && tsJestCfg !== void 0 ? tsJestCfg : Object.create(null);
148
148
  this.compilerModule = importer_1.importer.typescript("Using \"ts-jest\" requires this package to be installed.", (_e = options.compiler) !== null && _e !== void 0 ? _e : 'typescript');
149
149
  this.isolatedModules = (_f = options.isolatedModules) !== null && _f !== void 0 ? _f : false;
150
150
  this.logger.debug({ compilerModule: this.compilerModule }, 'normalized compiler module config via ts-jest option');
151
- this._backportJestCfg();
152
- this._setupTsJestCfg(options);
153
- this._resolveTsCacheDir();
154
151
  this._matchablePatterns = __spread(this._jestCfg.testMatch, this._jestCfg.testRegex).filter(function (pattern) {
155
152
  return pattern instanceof RegExp || typeof pattern === 'string';
156
153
  });
@@ -158,9 +155,11 @@ var ConfigSet = (function () {
158
155
  (_b = this._matchablePatterns).push.apply(_b, __spread(constants_1.DEFAULT_JEST_TEST_MATCH));
159
156
  }
160
157
  this._matchTestFilePath = jest_util_1.globsToMatcher(this._matchablePatterns.filter(function (pattern) { return typeof pattern === 'string'; }));
158
+ this._setupTsJestCfg(options);
159
+ this._resolveTsCacheDir();
161
160
  }
162
- ConfigSet.prototype._backportJestCfg = function () {
163
- var config = backports_1.backportJestConfig(this.logger, this.jestConfig);
161
+ ConfigSet.prototype._backportJestCfg = function (jestCfg) {
162
+ var config = backports_1.backportJestConfig(this.logger, jestCfg);
164
163
  this.logger.debug({ jestConfig: config }, 'normalized jest config');
165
164
  this._jestCfg = config;
166
165
  };
@@ -0,0 +1,105 @@
1
+ export interface RawCompilerOptions {
2
+ charset?: string;
3
+ composite?: boolean;
4
+ declaration?: boolean;
5
+ declarationDir?: string | null;
6
+ diagnostics?: boolean;
7
+ disableReferencedProjectLoad?: boolean;
8
+ emitBOM?: boolean;
9
+ emitDeclarationOnly?: boolean;
10
+ incremental?: boolean;
11
+ tsBuildInfoFile?: string;
12
+ inlineSourceMap?: boolean;
13
+ inlineSources?: boolean;
14
+ jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
15
+ reactNamespace?: string;
16
+ jsxFactory?: string;
17
+ jsxFragmentFactory?: string;
18
+ jsxImportSource?: string;
19
+ listFiles?: boolean;
20
+ mapRoot?: string;
21
+ module?: 'CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | string;
22
+ moduleResolution?: 'Classic' | 'Node';
23
+ newLine?: 'crlf' | 'lf';
24
+ noEmit?: boolean;
25
+ noEmitHelpers?: boolean;
26
+ noEmitOnError?: boolean;
27
+ noImplicitAny?: boolean;
28
+ noImplicitThis?: boolean;
29
+ noUnusedLocals?: boolean;
30
+ noUnusedParameters?: boolean;
31
+ noLib?: boolean;
32
+ noResolve?: boolean;
33
+ noStrictGenericChecks?: boolean;
34
+ skipDefaultLibCheck?: boolean;
35
+ skipLibCheck?: boolean;
36
+ outFile?: string;
37
+ outDir?: string;
38
+ preserveConstEnums?: boolean;
39
+ preserveSymlinks?: boolean;
40
+ preserveWatchOutput?: boolean;
41
+ pretty?: boolean;
42
+ removeComments?: boolean;
43
+ rootDir?: string;
44
+ isolatedModules?: boolean;
45
+ sourceMap?: boolean;
46
+ sourceRoot?: string;
47
+ suppressExcessPropertyErrors?: boolean;
48
+ suppressImplicitAnyIndexErrors?: boolean;
49
+ target?: 'ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ESNext' | string;
50
+ watch?: boolean;
51
+ fallbackPolling?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling';
52
+ watchDirectory?: 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling';
53
+ watchFile?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory';
54
+ experimentalDecorators?: boolean;
55
+ emitDecoratorMetadata?: boolean;
56
+ allowUnusedLabels?: boolean;
57
+ noImplicitReturns?: boolean;
58
+ noUncheckedIndexedAccess?: boolean;
59
+ noFallthroughCasesInSwitch?: boolean;
60
+ allowUnreachableCode?: boolean;
61
+ forceConsistentCasingInFileNames?: boolean;
62
+ generateCpuProfile?: string;
63
+ baseUrl?: string;
64
+ paths?: {
65
+ [k: string]: string[];
66
+ };
67
+ plugins?: {
68
+ name?: string;
69
+ [k: string]: unknown;
70
+ }[];
71
+ rootDirs?: string[];
72
+ typeRoots?: string[];
73
+ types?: string[];
74
+ traceResolution?: boolean;
75
+ allowJs?: boolean;
76
+ noErrorTruncation?: boolean;
77
+ allowSyntheticDefaultImports?: boolean;
78
+ noImplicitUseStrict?: boolean;
79
+ listEmittedFiles?: boolean;
80
+ disableSizeLimit?: boolean;
81
+ lib?: ('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.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.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.ImportScripts')[];
82
+ strictNullChecks?: boolean;
83
+ maxNodeModuleJsDepth?: number;
84
+ importHelpers?: boolean;
85
+ importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
86
+ alwaysStrict?: boolean;
87
+ strict?: boolean;
88
+ strictBindCallApply?: boolean;
89
+ downlevelIteration?: boolean;
90
+ checkJs?: boolean;
91
+ strictFunctionTypes?: boolean;
92
+ strictPropertyInitialization?: boolean;
93
+ esModuleInterop?: boolean;
94
+ allowUmdGlobalAccess?: boolean;
95
+ keyofStringsOnly?: boolean;
96
+ useDefineForClassFields?: boolean;
97
+ declarationMap?: boolean;
98
+ resolveJsonModule?: boolean;
99
+ assumeChangesOnlyAffectDirectDependencies?: boolean;
100
+ extendedDiagnostics?: boolean;
101
+ listFilesOnly?: boolean;
102
+ disableSourceOfProjectReferenceRedirect?: boolean;
103
+ disableSolutionSearching?: boolean;
104
+ [k: string]: unknown;
105
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Config } from '@jest/types';
2
2
  import type * as _babel from 'babel__core';
3
3
  import type * as _ts from 'typescript';
4
+ import type { RawCompilerOptions } from './tsconfig-raw';
4
5
  export declare type TTypeScript = typeof _ts;
5
6
  export declare type BabelConfig = _babel.TransformOptions;
6
7
  export interface AstTransformer<T = Record<string, unknown>> {
@@ -13,8 +14,8 @@ export interface ConfigCustomTransformer {
13
14
  afterDeclarations?: (string | AstTransformer)[];
14
15
  }
15
16
  export interface TsJestGlobalOptions {
16
- tsConfig?: boolean | string | _ts.CompilerOptions;
17
- tsconfig?: boolean | string | _ts.CompilerOptions;
17
+ tsConfig?: boolean | string | RawCompilerOptions;
18
+ tsconfig?: boolean | string | RawCompilerOptions;
18
19
  packageJson?: boolean | string | Record<string, unknown>;
19
20
  isolatedModules?: boolean;
20
21
  compiler?: string;
@@ -15,11 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.backportTsJestDebugEnvVar = exports.backportJestConfig = void 0;
16
16
  var bs_logger_1 = require("bs-logger");
17
17
  var messages_1 = require("./messages");
18
+ var constants_1 = require("../constants");
18
19
  var context = (_a = {}, _a[bs_logger_1.LogContexts.namespace] = 'backports', _a);
19
20
  exports.backportJestConfig = function (logger, config) {
21
+ var _a, _b;
20
22
  logger.debug(__assign(__assign({}, context), { config: config }), 'backporting config');
21
- var _a = (config || {}).globals, globals = _a === void 0 ? {} : _a;
22
- var _b = globals["ts-jest"], tsJest = _b === void 0 ? {} : _b;
23
+ var _c = (config || {}).globals, globals = _c === void 0 ? {} : _c;
24
+ var _d = globals["ts-jest"], tsJest = _d === void 0 ? {} : _d;
23
25
  var mergeTsJest = {};
24
26
  var hadWarnings = false;
25
27
  var warnConfig = function (oldPath, newPath, note) {
@@ -85,7 +87,7 @@ exports.backportJestConfig = function (logger, config) {
85
87
  if (hadWarnings) {
86
88
  logger.warn(context, "Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.");
87
89
  }
88
- return __assign(__assign({}, config), { globals: __assign(__assign({}, globals), { 'ts-jest': __assign(__assign({}, mergeTsJest), tsJest) }) });
90
+ return __assign(__assign({}, config), { testMatch: (_a = config.testMatch) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_JEST_TEST_MATCH, testRegex: (_b = config.testRegex) !== null && _b !== void 0 ? _b : [], globals: __assign(__assign({}, globals), { 'ts-jest': __assign(__assign({}, mergeTsJest), tsJest) }) });
89
91
  };
90
92
  exports.backportTsJestDebugEnvVar = function (logger) {
91
93
  if ('TS_JEST_DEBUG' in process.env) {
@@ -1 +1 @@
1
- export {};
1
+ export declare let rootLogger: import("bs-logger/dist/logger").Logger;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "26.5.1",
3
+ "version": "26.5.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "description": "A preprocessor with source maps support to help use TypeScript with Jest",
10
10
  "scripts": {
11
- "prebuild": "node scripts/clean-dist.js",
11
+ "prebuild": "node scripts/pre-build.js",
12
12
  "build": "tsc -p tsconfig.build.json",
13
13
  "postbuild": "node scripts/post-build.js",
14
14
  "clean": "node scripts/clean.js",
@@ -32,7 +32,8 @@
32
32
  "prepublishOnly": "npm run test",
33
33
  "preversion": "npm run test",
34
34
  "update:e2e": "node scripts/update-e2e-templates.js",
35
- "version": "npm run changelog && git add CHANGELOG.md"
35
+ "version": "npm run changelog && git add CHANGELOG.md",
36
+ "raw-tsconfig-types": "node scripts/tsconfig-raw-types.js"
36
37
  },
37
38
  "repository": {
38
39
  "type": "git",
@@ -57,7 +58,6 @@
57
58
  },
58
59
  "homepage": "https://kulshekhar.github.io/ts-jest",
59
60
  "dependencies": {
60
- "@types/jest": "26.x",
61
61
  "bs-logger": "0.x",
62
62
  "buffer-from": "1.x",
63
63
  "fast-json-stable-stringify": "2.x",
@@ -89,6 +89,7 @@
89
89
  "@types/buffer-from": "latest",
90
90
  "@types/cross-spawn": "latest",
91
91
  "@types/fs-extra": "latest",
92
+ "@types/jest": "26.x",
92
93
  "@types/js-yaml": "latest",
93
94
  "@types/json5": "latest",
94
95
  "@types/lodash": "4.x",
@@ -114,7 +115,9 @@
114
115
  "husky": "4.x",
115
116
  "jest": "26.x",
116
117
  "js-yaml": "latest",
118
+ "json-schema-to-typescript": "^10.1.3",
117
119
  "lint-staged": "latest",
120
+ "node-fetch": "^2.6.1",
118
121
  "npm-run-all": "latest",
119
122
  "prettier": "2.x",
120
123
  "source-map": "latest",