ts-jest 27.1.2 → 28.0.0-next.0
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 +1 -1
- package/CHANGELOG.md +46 -0
- package/dist/compiler/index.d.ts +0 -1
- package/dist/compiler/index.js +5 -2
- package/dist/compiler/ts-compiler.d.ts +3 -2
- package/dist/compiler/ts-compiler.js +14 -5
- package/dist/compiler/ts-jest-compiler.d.ts +2 -1
- package/dist/config/config-set.js +5 -4
- package/dist/config/index.js +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -4
- package/dist/legacy/index.d.ts +6 -0
- package/dist/legacy/index.js +21 -0
- package/dist/{ts-jest-transformer.d.ts → legacy/ts-jest-transformer.d.ts} +7 -6
- package/dist/{ts-jest-transformer.js → legacy/ts-jest-transformer.js} +87 -43
- package/dist/transformers/hoist-jest.d.ts +1 -1
- package/dist/transformers/hoist-jest.js +5 -8
- package/dist/types.d.ts +6 -4
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +5 -1
- package/dist/utils/version-checkers.js +3 -3
- package/legacy.js +1 -0
- package/package.json +19 -20
- package/dist/compiler/compiler-utils.d.ts +0 -2
- package/dist/compiler/compiler-utils.js +0 -24
- package/dist/utils/testing.d.ts +0 -33
- package/dist/utils/testing.js +0 -8
- package/utils/index.d.ts +0 -3
- package/utils/index.js +0 -28
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c3a0630ac8f5e24c57ab4b3d834f719f3ad740f2
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
+
# [28.0.0-next.0](https://github.com/kulshekhar/ts-jest/compare/v27.1.3...v28.0.0-next.0) (2022-04-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **legacy** invoke Babel `processAsync` for `babel-jest` in ESM mode instead of `process` ([#3430](https://github.com/kulshekhar/ts-jest/issues/3430)) ([0d7356c](https://github.com/kulshekhar/ts-jest/commit/0d7356cd767a924e5b57e3a93679eef4ca8fae51))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** drop support for Node.js 10 ([#3332](https://github.com/kulshekhar/ts-jest/issues/3332)) ([7a9aa61](https://github.com/kulshekhar/ts-jest/commit/7a9aa615ea0be881105676a17d5bd655afdc27f5))
|
|
12
|
+
* **core:** remove `mocked` testing util ([#3333](https://github.com/kulshekhar/ts-jest/issues/3333)) ([2d9017d](https://github.com/kulshekhar/ts-jest/commit/2d9017ddfea39f45aa991876b314d1dbe4a36aad))
|
|
13
|
+
* **core:** remove `ts-jest/utils` sub path export ([#3334](https://github.com/kulshekhar/ts-jest/issues/3334)) ([9f253d3](https://github.com/kulshekhar/ts-jest/commit/9f253d31dfcefa35ae00049d0d2dc4a3fe1b2f34))
|
|
14
|
+
* mark `TsJestTransformer` as legacy ([#3451](https://github.com/kulshekhar/ts-jest/issues/3451)) ([b090179](https://github.com/kulshekhar/ts-jest/commit/b0901799adc519959a954dba5e7b8fc8b97a9665))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* Minimum support TypeScript version is now **4.3** since Jest 28 requires it
|
|
20
|
+
* Jest 28 is required
|
|
21
|
+
* **core:** Any imports `ts-jest/utils` should be replaced with `ts-jest`.
|
|
22
|
+
* **core:** Starting from Jest 27.4, `mocked` has been integrated into Jest repo.
|
|
23
|
+
* **core:** Support for Node.js v10 has been removed as Jest drops support for it
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## [27.1.4](https://github.com/kulshekhar/ts-jest/compare/v27.1.3...v27.1.4) (2022-03-24)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **compiler:** revert [#3194](https://github.com/kulshekhar/ts-jest/issues/3194) ([#3362](https://github.com/kulshekhar/ts-jest/issues/3362)) ([2b7dffe](https://github.com/kulshekhar/ts-jest/commit/2b7dffeac940f779922c43cefba3f741a3911b49)), closes [#3272](https://github.com/kulshekhar/ts-jest/issues/3272)
|
|
33
|
+
* remove `esbuild` from peer dependency ([#3360](https://github.com/kulshekhar/ts-jest/issues/3360)) ([8c8c1ca](https://github.com/kulshekhar/ts-jest/commit/8c8c1ca615b1edeedc9f4282557c28e82acee543)), closes [#3346](https://github.com/kulshekhar/ts-jest/issues/3346)
|
|
34
|
+
* support Babel config file with `.cjs` extension ([#3361](https://github.com/kulshekhar/ts-jest/issues/3361)) ([5e5ac4a](https://github.com/kulshekhar/ts-jest/commit/5e5ac4ac286bdcce157d0bdc31f3a57202fdbdfe)), closes [#3335](https://github.com/kulshekhar/ts-jest/issues/3335)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [27.1.3](https://github.com/kulshekhar/ts-jest/compare/v27.1.2...v27.1.3) (2022-01-14)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
* **compiler:** update memory cache for compiler using received file content ([#3194](https://github.com/kulshekhar/ts-jest/issues/3194)) ([e4d9541](https://github.com/kulshekhar/ts-jest/commit/e4d9541f262ca14cb25563c757c0f2345dbf5c51))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
1
47
|
## [27.1.2](https://github.com/kulshekhar/ts-jest/compare/v27.1.1...v27.1.2) (2021-12-15)
|
|
2
48
|
|
|
3
49
|
|
package/dist/compiler/index.d.ts
CHANGED
package/dist/compiler/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./compiler-utils"), exports);
|
|
14
17
|
__exportStar(require("./ts-compiler"), exports);
|
|
15
18
|
__exportStar(require("./ts-jest-compiler"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { TransformedSource } from '@jest/transform';
|
|
1
2
|
import { Logger } from 'bs-logger';
|
|
2
|
-
import type {
|
|
3
|
+
import type { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
|
|
3
4
|
import type { ConfigSet } from '../config';
|
|
4
5
|
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../types';
|
|
5
6
|
export declare class TsCompiler implements TsCompilerInstance {
|
|
@@ -14,7 +15,7 @@ export declare class TsCompiler implements TsCompilerInstance {
|
|
|
14
15
|
program: Program | undefined;
|
|
15
16
|
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
|
16
17
|
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
17
|
-
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions):
|
|
18
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource;
|
|
18
19
|
protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
|
|
19
20
|
protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
|
|
20
21
|
}
|
|
@@ -57,7 +57,6 @@ var lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
|
|
57
57
|
var constants_1 = require("../constants");
|
|
58
58
|
var utils_1 = require("../utils");
|
|
59
59
|
var messages_1 = require("../utils/messages");
|
|
60
|
-
var compiler_utils_1 = require("./compiler-utils");
|
|
61
60
|
var TsCompiler = (function () {
|
|
62
61
|
function TsCompiler(configSet, runtimeCacheFS) {
|
|
63
62
|
var _a;
|
|
@@ -137,7 +136,9 @@ var TsCompiler = (function () {
|
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
138
|
this._logger.warn((0, 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 }));
|
|
140
|
-
return
|
|
139
|
+
return {
|
|
140
|
+
code: fileContent,
|
|
141
|
+
};
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
144
|
if (!output.outputFiles.length) {
|
|
@@ -146,8 +147,13 @@ var TsCompiler = (function () {
|
|
|
146
147
|
}));
|
|
147
148
|
}
|
|
148
149
|
return this._compilerOptions.sourceMap
|
|
149
|
-
?
|
|
150
|
-
|
|
150
|
+
? {
|
|
151
|
+
code: output.outputFiles[1].text,
|
|
152
|
+
map: output.outputFiles[0].text,
|
|
153
|
+
}
|
|
154
|
+
: {
|
|
155
|
+
code: output.outputFiles[0].text,
|
|
156
|
+
};
|
|
151
157
|
}
|
|
152
158
|
else {
|
|
153
159
|
this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling as isolated module');
|
|
@@ -155,7 +161,10 @@ var TsCompiler = (function () {
|
|
|
155
161
|
if (result.diagnostics && this.configSet.shouldReportDiagnostics(fileName)) {
|
|
156
162
|
this.configSet.raiseDiagnostics(result.diagnostics, fileName, this._logger);
|
|
157
163
|
}
|
|
158
|
-
return
|
|
164
|
+
return {
|
|
165
|
+
code: result.outputText,
|
|
166
|
+
map: result.sourceMapText,
|
|
167
|
+
};
|
|
159
168
|
}
|
|
160
169
|
};
|
|
161
170
|
TsCompiler.prototype._transpileOutput = function (fileContent, fileName) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { TransformedSource } from '@jest/transform';
|
|
1
2
|
import type { ConfigSet } from '../config';
|
|
2
3
|
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types';
|
|
3
4
|
export declare class TsJestCompiler implements CompilerInstance {
|
|
4
5
|
private readonly _compilerInstance;
|
|
5
6
|
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
|
6
7
|
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
7
|
-
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions):
|
|
8
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource;
|
|
8
9
|
}
|
|
@@ -181,7 +181,8 @@ var ConfigSet = (function () {
|
|
|
181
181
|
var baseBabelCfg = { cwd: this.cwd };
|
|
182
182
|
if (typeof options.babelConfig === 'string') {
|
|
183
183
|
var babelCfgPath = this.resolvePath(options.babelConfig);
|
|
184
|
-
|
|
184
|
+
var babelFileExtName = (0, path_1.extname)(options.babelConfig);
|
|
185
|
+
if (babelFileExtName === '.js' || babelFileExtName === '.cjs') {
|
|
185
186
|
this.babelConfig = __assign(__assign({}, baseBabelCfg), require(babelCfgPath));
|
|
186
187
|
}
|
|
187
188
|
else {
|
|
@@ -197,7 +198,7 @@ var ConfigSet = (function () {
|
|
|
197
198
|
this.logger.debug({ babelConfig: this.babelConfig }, 'normalized babel config via ts-jest option');
|
|
198
199
|
this.babelJestTransformer = importer_1.importer
|
|
199
200
|
.babelJest("Using \"babel-jest\" requires this package to be installed.")
|
|
200
|
-
.
|
|
201
|
+
.createTransformer(this.babelConfig);
|
|
201
202
|
this.logger.debug('created babel-jest transformer');
|
|
202
203
|
}
|
|
203
204
|
var diagnosticsOpt = (_b = options.diagnostics) !== null && _b !== void 0 ? _b : true;
|
|
@@ -371,8 +372,8 @@ var ConfigSet = (function () {
|
|
|
371
372
|
_b);
|
|
372
373
|
if (compilationTarget &&
|
|
373
374
|
!this.babelConfig &&
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
nodeJsVer.startsWith('v12') &&
|
|
376
|
+
compilationTarget > this.compilerModule.ScriptTarget.ES2019) {
|
|
376
377
|
var message = (0, messages_1.interpolate)("There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping", {
|
|
377
378
|
nodeJsVer: process.version,
|
|
378
379
|
compilationTarget: TARGET_TO_VERSION_MAPPING[compilationTarget],
|
package/dist/config/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { TsJestTransformer } from './
|
|
1
|
+
import { TsJestTransformer } from './legacy';
|
|
2
|
+
export * from './legacy';
|
|
2
3
|
export * from './constants';
|
|
3
4
|
export * from './compiler';
|
|
4
5
|
export * from './config';
|
|
5
6
|
export * from './presets/create-jest-preset';
|
|
6
7
|
export * from './utils';
|
|
7
8
|
export * from './raw-compiler-options';
|
|
8
|
-
export * from './ts-jest-transformer';
|
|
9
9
|
export * from './types';
|
|
10
10
|
declare const _default: {
|
|
11
|
-
createTransformer
|
|
11
|
+
createTransformer(): TsJestTransformer;
|
|
12
12
|
};
|
|
13
13
|
export default _default;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,15 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
var
|
|
17
|
+
var legacy_1 = require("./legacy");
|
|
18
|
+
__exportStar(require("./legacy"), exports);
|
|
14
19
|
__exportStar(require("./constants"), exports);
|
|
15
20
|
__exportStar(require("./compiler"), exports);
|
|
16
21
|
__exportStar(require("./config"), exports);
|
|
17
22
|
__exportStar(require("./presets/create-jest-preset"), exports);
|
|
18
23
|
__exportStar(require("./utils"), exports);
|
|
19
24
|
__exportStar(require("./raw-compiler-options"), exports);
|
|
20
|
-
__exportStar(require("./ts-jest-transformer"), exports);
|
|
21
25
|
__exportStar(require("./types"), exports);
|
|
22
26
|
exports.default = {
|
|
23
|
-
createTransformer: function () {
|
|
27
|
+
createTransformer: function () {
|
|
28
|
+
return new legacy_1.TsJestTransformer(true);
|
|
29
|
+
},
|
|
24
30
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var ts_jest_transformer_1 = require("./ts-jest-transformer");
|
|
18
|
+
__exportStar(require("./ts-jest-transformer"), exports);
|
|
19
|
+
exports.default = {
|
|
20
|
+
createTransformer: function () { return new ts_jest_transformer_1.TsJestTransformer(); },
|
|
21
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SyncTransformer, TransformedSource } from '@jest/transform';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest } from './types';
|
|
2
|
+
import { ConfigSet } from '../config';
|
|
3
|
+
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest } from '../types';
|
|
5
4
|
export declare class TsJestTransformer implements SyncTransformer {
|
|
6
5
|
private readonly _logger;
|
|
7
6
|
protected _compiler: CompilerInstance;
|
|
@@ -9,12 +8,14 @@ export declare class TsJestTransformer implements SyncTransformer {
|
|
|
9
8
|
private _transformCfgStr;
|
|
10
9
|
private _depGraphs;
|
|
11
10
|
private _watchMode;
|
|
12
|
-
constructor();
|
|
11
|
+
constructor(isLegacy?: boolean);
|
|
13
12
|
private _configsFor;
|
|
14
13
|
protected _createConfigSet(config: ProjectConfigTsJest | undefined): ConfigSet;
|
|
15
14
|
protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;
|
|
16
|
-
process(
|
|
17
|
-
processAsync(sourceText: string, sourcePath:
|
|
15
|
+
process(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): TransformedSource;
|
|
16
|
+
processAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<TransformedSource>;
|
|
17
|
+
private processWithTs;
|
|
18
|
+
private runTsJestHook;
|
|
18
19
|
getCacheKey(fileContent: string, filePath: string, transformOptions: TransformOptionsTsJest): string;
|
|
19
20
|
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<string>;
|
|
20
21
|
private _getFsCachedResolvedModules;
|
|
@@ -78,21 +78,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
78
78
|
exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
|
|
79
79
|
var fs_1 = require("fs");
|
|
80
80
|
var path_1 = __importDefault(require("path"));
|
|
81
|
-
var compiler_1 = require("
|
|
82
|
-
var config_1 = require("
|
|
83
|
-
var constants_1 = require("
|
|
84
|
-
var utils_1 = require("
|
|
85
|
-
var importer_1 = require("
|
|
86
|
-
var messages_1 = require("
|
|
87
|
-
var sha1_1 = require("
|
|
88
|
-
var version_checkers_1 = require("
|
|
81
|
+
var compiler_1 = require("../compiler");
|
|
82
|
+
var config_1 = require("../config");
|
|
83
|
+
var constants_1 = require("../constants");
|
|
84
|
+
var utils_1 = require("../utils");
|
|
85
|
+
var importer_1 = require("../utils/importer");
|
|
86
|
+
var messages_1 = require("../utils/messages");
|
|
87
|
+
var sha1_1 = require("../utils/sha1");
|
|
88
|
+
var version_checkers_1 = require("../utils/version-checkers");
|
|
89
89
|
exports.CACHE_KEY_EL_SEPARATOR = '\x00';
|
|
90
90
|
var TsJestTransformer = (function () {
|
|
91
|
-
function TsJestTransformer() {
|
|
91
|
+
function TsJestTransformer(isLegacy) {
|
|
92
|
+
if (isLegacy === void 0) { isLegacy = false; }
|
|
92
93
|
this._depGraphs = new Map();
|
|
93
94
|
this._watchMode = false;
|
|
94
95
|
this._logger = utils_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
|
95
96
|
version_checkers_1.VersionCheckers.jest.warn();
|
|
97
|
+
if (isLegacy) {
|
|
98
|
+
this._logger.warn("Use 'ts-jest' entry point in v28 will resolve in refactored transformer. If you wish to use legacy transformer, please adjust your Jest 'transform' config. For example:\n module.exports = {\n transform: {\n '^.+\\\\.tsx?$': 'ts-jest/legacy'\n }\n }\n ");
|
|
99
|
+
}
|
|
96
100
|
this.getCacheKey = this.getCacheKey.bind(this);
|
|
97
101
|
this.getCacheKeyAsync = this.getCacheKeyAsync.bind(this);
|
|
98
102
|
this.process = this.process.bind(this);
|
|
@@ -128,7 +132,6 @@ var TsJestTransformer = (function () {
|
|
|
128
132
|
this._logger.info('no matching config-set found, creating a new one');
|
|
129
133
|
configSet = this._createConfigSet(config);
|
|
130
134
|
var jest_1 = __assign({}, config);
|
|
131
|
-
jest_1.name = undefined;
|
|
132
135
|
jest_1.cacheDirectory = undefined;
|
|
133
136
|
this._transformCfgStr = "".concat(new utils_1.JsonableValue(jest_1).serialized).concat(configSet.cacheSuffix);
|
|
134
137
|
this._createCompiler(configSet, cacheFS);
|
|
@@ -153,33 +156,75 @@ var TsJestTransformer = (function () {
|
|
|
153
156
|
TsJestTransformer.prototype._createCompiler = function (configSet, cacheFS) {
|
|
154
157
|
this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
|
|
155
158
|
};
|
|
156
|
-
TsJestTransformer.prototype.process = function (
|
|
157
|
-
this._logger.debug({ fileName:
|
|
158
|
-
var result;
|
|
159
|
+
TsJestTransformer.prototype.process = function (sourceText, sourcePath, transformOptions) {
|
|
160
|
+
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
|
|
159
161
|
var configs = this._configsFor(transformOptions);
|
|
160
|
-
var shouldStringifyContent = configs.shouldStringifyContent(
|
|
162
|
+
var shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
|
161
163
|
var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var hooks;
|
|
167
|
-
if (hooksFile) {
|
|
168
|
-
hooksFile = path_1.default.resolve(configs.cwd, hooksFile);
|
|
169
|
-
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
|
164
|
+
var result = this.processWithTs(sourceText, sourcePath, transformOptions);
|
|
165
|
+
if (babelJest) {
|
|
166
|
+
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
|
167
|
+
result = babelJest.process(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }));
|
|
170
168
|
}
|
|
169
|
+
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
|
170
|
+
return result;
|
|
171
|
+
};
|
|
172
|
+
TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var _this = this;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
|
|
177
|
+
return [2, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
|
178
|
+
var configs, shouldStringifyContent, babelJest, result;
|
|
179
|
+
return __generator(this, function (_a) {
|
|
180
|
+
switch (_a.label) {
|
|
181
|
+
case 0:
|
|
182
|
+
configs = this._configsFor(transformOptions);
|
|
183
|
+
shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
|
184
|
+
babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
|
185
|
+
result = this.processWithTs(sourceText, sourcePath, transformOptions);
|
|
186
|
+
if (!babelJest) return [3, 2];
|
|
187
|
+
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
|
188
|
+
return [4, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
|
|
189
|
+
case 1:
|
|
190
|
+
result = _a.sent();
|
|
191
|
+
_a.label = 2;
|
|
192
|
+
case 2:
|
|
193
|
+
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
|
194
|
+
resolve(result);
|
|
195
|
+
return [2];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}); })];
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
TsJestTransformer.prototype.processWithTs = function (sourceText, sourcePath, transformOptions) {
|
|
203
|
+
var result;
|
|
204
|
+
var configs = this._configsFor(transformOptions);
|
|
205
|
+
var shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
|
206
|
+
var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
|
207
|
+
var isDefinitionFile = sourcePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
|
|
208
|
+
var isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
|
|
209
|
+
var isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
|
|
171
210
|
if (shouldStringifyContent) {
|
|
172
|
-
result =
|
|
211
|
+
result = {
|
|
212
|
+
code: "module.exports=".concat((0, utils_1.stringify)(sourceText)),
|
|
213
|
+
};
|
|
173
214
|
}
|
|
174
215
|
else if (isDefinitionFile) {
|
|
175
|
-
result =
|
|
216
|
+
result = {
|
|
217
|
+
code: '',
|
|
218
|
+
};
|
|
176
219
|
}
|
|
177
220
|
else if (!configs.parsedTsConfig.options.allowJs && isJsFile) {
|
|
178
|
-
this._logger.warn({ fileName:
|
|
179
|
-
result =
|
|
221
|
+
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)("Got a `.js` file to compile while `allowJs` option is not set to `true` (file: {{path}}). To fix this:\n - if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)\n - if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore", { path: sourcePath }));
|
|
222
|
+
result = {
|
|
223
|
+
code: sourceText,
|
|
224
|
+
};
|
|
180
225
|
}
|
|
181
226
|
else if (isJsFile || isTsFile) {
|
|
182
|
-
result = this._compiler.getCompiledOutput(
|
|
227
|
+
result = this._compiler.getCompiledOutput(sourceText, sourcePath, {
|
|
183
228
|
depGraphs: this._depGraphs,
|
|
184
229
|
supportsStaticESM: transformOptions.supportsStaticESM,
|
|
185
230
|
watchMode: this._watchMode,
|
|
@@ -187,29 +232,28 @@ var TsJestTransformer = (function () {
|
|
|
187
232
|
}
|
|
188
233
|
else {
|
|
189
234
|
var message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore.";
|
|
190
|
-
this._logger.warn({ fileName:
|
|
191
|
-
result =
|
|
235
|
+
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)(message, { path: sourcePath }));
|
|
236
|
+
result = {
|
|
237
|
+
code: sourceText,
|
|
238
|
+
};
|
|
192
239
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
240
|
+
return result;
|
|
241
|
+
};
|
|
242
|
+
TsJestTransformer.prototype.runTsJestHook = function (sourcePath, sourceText, transformOptions, compiledOutput) {
|
|
243
|
+
var hooksFile = process.env.TS_JEST_HOOKS;
|
|
244
|
+
var hooks;
|
|
245
|
+
if (hooksFile) {
|
|
246
|
+
hooksFile = path_1.default.resolve(this._configsFor(transformOptions).cwd, hooksFile);
|
|
247
|
+
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
|
196
248
|
}
|
|
197
249
|
if (hooks === null || hooks === void 0 ? void 0 : hooks.afterProcess) {
|
|
198
|
-
this._logger.debug({ fileName:
|
|
199
|
-
var newResult = hooks.afterProcess([
|
|
250
|
+
this._logger.debug({ fileName: sourcePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
|
|
251
|
+
var newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
|
|
200
252
|
if (newResult) {
|
|
201
253
|
return newResult;
|
|
202
254
|
}
|
|
203
255
|
}
|
|
204
|
-
return
|
|
205
|
-
};
|
|
206
|
-
TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
|
|
207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var _this = this;
|
|
209
|
-
return __generator(this, function (_a) {
|
|
210
|
-
return [2, new Promise(function (resolve) { return resolve(_this.process(sourceText, sourcePath, transformOptions)); })];
|
|
211
|
-
});
|
|
212
|
-
});
|
|
256
|
+
return compiledOutput;
|
|
213
257
|
};
|
|
214
258
|
TsJestTransformer.prototype.getCacheKey = function (fileContent, filePath, transformOptions) {
|
|
215
259
|
var _a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type _ts from 'typescript';
|
|
2
2
|
import type { TsCompilerInstance } from '../types';
|
|
3
|
-
export declare const version =
|
|
3
|
+
export declare const version = 4;
|
|
4
4
|
export declare const name = "hoist-jest";
|
|
5
5
|
export declare function factory({ configSet }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.factory = exports.name = exports.version = void 0;
|
|
4
4
|
var bs_logger_1 = require("bs-logger");
|
|
5
|
-
exports.version =
|
|
5
|
+
exports.version = 4;
|
|
6
6
|
exports.name = 'hoist-jest';
|
|
7
7
|
var HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock', 'deepUnmock'];
|
|
8
8
|
var JEST_GLOBALS_MODULE_NAME = '@jest/globals';
|
|
@@ -11,7 +11,6 @@ function factory(_a) {
|
|
|
11
11
|
var configSet = _a.configSet;
|
|
12
12
|
var logger = configSet.logger.child({ namespace: exports.name });
|
|
13
13
|
var ts = configSet.compilerModule;
|
|
14
|
-
var tsFactory = ts.factory ? ts.factory : ts;
|
|
15
14
|
var importNamesOfJestObj = [];
|
|
16
15
|
var isJestGlobalImport = function (node) {
|
|
17
16
|
return (ts.isImportDeclaration(node) &&
|
|
@@ -71,8 +70,8 @@ function factory(_a) {
|
|
|
71
70
|
var visitor = function (node) {
|
|
72
71
|
var resultNode = ts.visitEachChild(node, visitor, ctx);
|
|
73
72
|
if (ts.isBlock(resultNode) && canHoistInBlockScope(resultNode)) {
|
|
74
|
-
var newNodeArrayStatements =
|
|
75
|
-
return
|
|
73
|
+
var newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
|
74
|
+
return ts.factory.updateBlock(resultNode, newNodeArrayStatements);
|
|
76
75
|
}
|
|
77
76
|
else {
|
|
78
77
|
if (ts.isSourceFile(resultNode)) {
|
|
@@ -91,11 +90,9 @@ function factory(_a) {
|
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
});
|
|
94
|
-
var newNodeArrayStatements =
|
|
93
|
+
var newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
|
95
94
|
importNamesOfJestObj.length = 0;
|
|
96
|
-
return ts.factory
|
|
97
|
-
? ts.factory.updateSourceFile(resultNode, newNodeArrayStatements, resultNode.isDeclarationFile, resultNode.referencedFiles, resultNode.typeReferenceDirectives, resultNode.hasNoDefaultLib, resultNode.libReferenceDirectives)
|
|
98
|
-
: ts.updateSourceFileNode(resultNode, newNodeArrayStatements, resultNode.isDeclarationFile, resultNode.referencedFiles, resultNode.typeReferenceDirectives, resultNode.hasNoDefaultLib, resultNode.libReferenceDirectives);
|
|
95
|
+
return ts.factory.updateSourceFile(resultNode, newNodeArrayStatements, resultNode.isDeclarationFile, resultNode.referencedFiles, resultNode.typeReferenceDirectives, resultNode.hasNoDefaultLib, resultNode.libReferenceDirectives);
|
|
99
96
|
}
|
|
100
97
|
return resultNode;
|
|
101
98
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { TransformOptions } from '@jest/transform';
|
|
1
|
+
import type { TransformedSource, TransformOptions } from '@jest/transform';
|
|
2
2
|
import type { Config } from '@jest/types';
|
|
3
|
+
import type * as babelJest from 'babel-jest';
|
|
3
4
|
import type * as _babel from 'babel__core';
|
|
4
5
|
import type * as _ts from 'typescript';
|
|
5
6
|
import type { ConfigSet } from './config';
|
|
@@ -11,6 +12,7 @@ declare module '@jest/types' {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
export declare type TBabelJest = typeof babelJest;
|
|
14
16
|
export declare type TTypeScript = typeof _ts;
|
|
15
17
|
export interface TEsBuild {
|
|
16
18
|
transformSync(input: string, options?: {
|
|
@@ -41,7 +43,7 @@ export interface TsJestGlobalOptions {
|
|
|
41
43
|
diagnostics?: boolean | {
|
|
42
44
|
pretty?: boolean;
|
|
43
45
|
ignoreCodes?: number | string | Array<number | string>;
|
|
44
|
-
exclude?:
|
|
46
|
+
exclude?: string[];
|
|
45
47
|
warnOnly?: boolean;
|
|
46
48
|
};
|
|
47
49
|
babelConfig?: boolean | string | BabelConfig;
|
|
@@ -51,7 +53,7 @@ export interface TsJestGlobalOptions {
|
|
|
51
53
|
export interface TsJestDiagnosticsCfg {
|
|
52
54
|
pretty: boolean;
|
|
53
55
|
ignoreCodes: number[];
|
|
54
|
-
exclude:
|
|
56
|
+
exclude: string[];
|
|
55
57
|
throws: boolean;
|
|
56
58
|
warnOnly?: boolean;
|
|
57
59
|
}
|
|
@@ -79,7 +81,7 @@ export interface TsJestCompileOptions {
|
|
|
79
81
|
}
|
|
80
82
|
export interface CompilerInstance {
|
|
81
83
|
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
|
82
|
-
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions):
|
|
84
|
+
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): TransformedSource;
|
|
83
85
|
}
|
|
84
86
|
export interface TsCompilerInstance extends CompilerInstance {
|
|
85
87
|
configSet: ConfigSet;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export * from './json';
|
|
2
2
|
export * from './jsonable-value';
|
|
3
3
|
export * from './logger';
|
|
4
|
-
export type { MockedObject, MockedObjectDeep, MockedFunctionDeep, MockedFunction, MaybeMockedConstructor, MaybeMocked, MaybeMockedDeep, ConstructorArgumentsOf, MockableFunction, ArgumentsOf, MockWithArgs, PropertyKeysOf, MethodKeysOf, } from './testing';
|
package/dist/utils/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -7,9 +7,9 @@ var logger_1 = require("./logger");
|
|
|
7
7
|
var messages_1 = require("./messages");
|
|
8
8
|
var logger = logger_1.rootLogger.child({ namespace: 'versions' });
|
|
9
9
|
exports.VersionCheckers = {
|
|
10
|
-
jest: createVersionChecker('jest', ">=
|
|
11
|
-
typescript: createVersionChecker('typescript', ">=3
|
|
12
|
-
babelJest: createVersionChecker('babel-jest', ">=
|
|
10
|
+
jest: createVersionChecker('jest', ">=28.0.0-alpha.11 <29"),
|
|
11
|
+
typescript: createVersionChecker('typescript', ">=4.3 <5"),
|
|
12
|
+
babelJest: createVersionChecker('babel-jest', ">=28.0.0-alpha.11 <29"),
|
|
13
13
|
babelCore: createVersionChecker('@babel/core', ">=7.0.0-beta.0 <8"),
|
|
14
14
|
};
|
|
15
15
|
function checkVersion(name, expectedRange, action) {
|
package/legacy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/legacy')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "28.0.0-next.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"pretest": "tsc -p tsconfig.spec.json --noEmit && node scripts/prepare-test.js",
|
|
15
15
|
"test": "jest",
|
|
16
16
|
"test-examples": "node scripts/test-examples.js",
|
|
17
|
-
"lint": "
|
|
18
|
-
"lint-fix": "
|
|
17
|
+
"lint": "eslint --ext .js,.ts .",
|
|
18
|
+
"lint-fix": "eslint --fix --ext .js,.ts .",
|
|
19
19
|
"lint-prettier": "prettier '**/*.{yml,yaml,md}' --write",
|
|
20
20
|
"lint-prettier-ci": "prettier '**/*.{yml,yaml,md}' --check",
|
|
21
21
|
"doc": "cd website && npm run start",
|
|
22
22
|
"doc:build": "cd website && npm run build",
|
|
23
|
-
"changelog": "
|
|
23
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
|
24
24
|
"prepare": "npm run build",
|
|
25
25
|
"prepublishOnly": "npm run test",
|
|
26
26
|
"preversion": "npm run test",
|
|
@@ -53,20 +53,19 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"bs-logger": "0.x",
|
|
55
55
|
"fast-json-stable-stringify": "2.x",
|
|
56
|
-
"jest-util": "
|
|
56
|
+
"jest-util": "28.0.0-alpha.9",
|
|
57
57
|
"json5": "2.x",
|
|
58
58
|
"lodash.memoize": "4.x",
|
|
59
59
|
"make-error": "1.x",
|
|
60
60
|
"semver": "7.x",
|
|
61
|
-
"yargs-parser": "20.x"
|
|
61
|
+
"yargs-parser": "^20.x"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
65
65
|
"@types/jest": "^27.0.0",
|
|
66
|
-
"babel-jest": "
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"typescript": ">=3.8 <5.0"
|
|
66
|
+
"babel-jest": "28.0.0-alpha.11",
|
|
67
|
+
"jest": "28.0.0-alpha.11",
|
|
68
|
+
"typescript": ">=4.3"
|
|
70
69
|
},
|
|
71
70
|
"peerDependenciesMeta": {
|
|
72
71
|
"@babel/core": {
|
|
@@ -90,10 +89,10 @@
|
|
|
90
89
|
}
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
93
|
-
"@commitlint/cli": "
|
|
94
|
-
"@commitlint/config-angular": "^
|
|
95
|
-
"@jest/transform": "
|
|
96
|
-
"@jest/types": "
|
|
92
|
+
"@commitlint/cli": "16.x",
|
|
93
|
+
"@commitlint/config-angular": "^16.0.0",
|
|
94
|
+
"@jest/transform": "28.0.0-alpha.11",
|
|
95
|
+
"@jest/types": "28.0.0-alpha.9",
|
|
97
96
|
"@types/babel__core": "7.x",
|
|
98
97
|
"@types/cross-spawn": "latest",
|
|
99
98
|
"@types/fs-extra": "latest",
|
|
@@ -103,9 +102,9 @@
|
|
|
103
102
|
"@types/lodash.memoize": "4.x",
|
|
104
103
|
"@types/lodash.set": "4.x",
|
|
105
104
|
"@types/micromatch": "4.x",
|
|
106
|
-
"@types/node": "
|
|
105
|
+
"@types/node": "17.0.25",
|
|
107
106
|
"@types/node-fetch": "^3.0.3",
|
|
108
|
-
"@types/react": "
|
|
107
|
+
"@types/react": "18.x",
|
|
109
108
|
"@types/rimraf": "^3.0.2",
|
|
110
109
|
"@types/semver": "latest",
|
|
111
110
|
"@types/yargs": "latest",
|
|
@@ -124,10 +123,10 @@
|
|
|
124
123
|
"eslint-plugin-prettier": "latest",
|
|
125
124
|
"execa": "5.1.1",
|
|
126
125
|
"fs-extra": "10.x",
|
|
127
|
-
"glob": "^
|
|
126
|
+
"glob": "^8.0.1",
|
|
128
127
|
"glob-gitignore": "latest",
|
|
129
128
|
"husky": "4.x",
|
|
130
|
-
"jest": "
|
|
129
|
+
"jest": "28.0.0-alpha.11",
|
|
131
130
|
"jest-snapshot-serializer-raw": "^1.2.0",
|
|
132
131
|
"js-yaml": "latest",
|
|
133
132
|
"json-schema-to-typescript": "^10.1.4",
|
|
@@ -136,7 +135,7 @@
|
|
|
136
135
|
"lodash.set": "^4.3.2",
|
|
137
136
|
"node-fetch": "^3.0.0",
|
|
138
137
|
"prettier": "^2.4.0",
|
|
139
|
-
"typescript": "~4.
|
|
138
|
+
"typescript": "~4.6.2"
|
|
140
139
|
},
|
|
141
140
|
"lint-staged": {
|
|
142
141
|
"*.{ts,tsx,js,jsx}": [
|
|
@@ -145,6 +144,6 @@
|
|
|
145
144
|
]
|
|
146
145
|
},
|
|
147
146
|
"engines": {
|
|
148
|
-
"node": "^
|
|
147
|
+
"node": "^12.13.0 || ^14.15.0 || ^16.13.0 || >=17.0.0"
|
|
149
148
|
}
|
|
150
149
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateOutput = exports.SOURCE_MAPPING_PREFIX = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
|
6
|
-
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
|
7
|
-
if (sourceMap) {
|
|
8
|
-
var base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
|
9
|
-
var sourceMapContent = "data:application/json;charset=utf-8;base64,".concat(base64Map);
|
|
10
|
-
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) +
|
|
11
|
-
sourceMapContent);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return outputText;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.updateOutput = updateOutput;
|
|
18
|
-
var updateSourceMap = function (sourceMapText, normalizedFileName) {
|
|
19
|
-
var sourceMap = JSON.parse(sourceMapText);
|
|
20
|
-
sourceMap.file = normalizedFileName;
|
|
21
|
-
sourceMap.sources = [normalizedFileName];
|
|
22
|
-
delete sourceMap.sourceRoot;
|
|
23
|
-
return (0, utils_1.stringify)(sourceMap);
|
|
24
|
-
};
|
package/dist/utils/testing.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
|
-
export declare type MockableFunction = (...args: any[]) => any;
|
|
3
|
-
export declare type MethodKeysOf<T> = {
|
|
4
|
-
[K in keyof T]: T[K] extends MockableFunction ? K : never;
|
|
5
|
-
}[keyof T];
|
|
6
|
-
export declare type PropertyKeysOf<T> = {
|
|
7
|
-
[K in keyof T]: T[K] extends MockableFunction ? never : K;
|
|
8
|
-
}[keyof T];
|
|
9
|
-
export declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
|
|
10
|
-
export declare type ConstructorArgumentsOf<T> = T extends new (...args: infer A) => any ? A : never;
|
|
11
|
-
export interface MockWithArgs<T extends MockableFunction> extends jest.MockInstance<ReturnType<T>, ArgumentsOf<T>> {
|
|
12
|
-
new (...args: ConstructorArgumentsOf<T>): T;
|
|
13
|
-
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
14
|
-
}
|
|
15
|
-
export declare type MaybeMockedConstructor<T> = T extends new (...args: any[]) => infer R ? jest.MockInstance<R, ConstructorArgumentsOf<T>> : T;
|
|
16
|
-
export declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
|
|
17
|
-
[K in keyof T]: T[K];
|
|
18
|
-
};
|
|
19
|
-
export declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
20
|
-
export declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
21
|
-
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunction<T[K]> : T[K];
|
|
22
|
-
} & {
|
|
23
|
-
[K in PropertyKeysOf<T>]: T[K];
|
|
24
|
-
};
|
|
25
|
-
export declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
26
|
-
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunctionDeep<T[K]> : T[K];
|
|
27
|
-
} & {
|
|
28
|
-
[K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]>;
|
|
29
|
-
};
|
|
30
|
-
export declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
31
|
-
export declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
32
|
-
export declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
33
|
-
export declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
package/dist/utils/testing.js
DELETED
package/utils/index.d.ts
DELETED
package/utils/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { pathsToModuleNameMapper } = require('../dist/config/paths-to-module-name-mapper')
|
|
2
|
-
const { createJestPreset } = require('../dist/presets/create-jest-preset')
|
|
3
|
-
const { mocked } = require('../dist/utils/testing')
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
get mocked() {
|
|
7
|
-
if (!process.env.DISABLE_MOCKED_WARNING) {
|
|
8
|
-
console.warn(
|
|
9
|
-
'\n`mocked` util function is now deprecated and has been moved to Jest repository,' +
|
|
10
|
-
' see https://github.com/facebook/jest/pull/12089. In `ts-jest` v28.0.0, `mocked` function will be completely removed.' +
|
|
11
|
-
' Users are encouraged to use to Jest v27.4.0 or above to have `mocked` function available from `jest-mock`. ' +
|
|
12
|
-
'One can disable this warning by setting environment variable process.env.DISABLE_MOCKED_WARNING=true\n'
|
|
13
|
-
)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return mocked
|
|
17
|
-
},
|
|
18
|
-
get createJestPreset() {
|
|
19
|
-
console.warn('ts-jest[main] (WARN) Replace any occurrences of "ts-jest/utils" with just "ts-jest".')
|
|
20
|
-
|
|
21
|
-
return createJestPreset
|
|
22
|
-
},
|
|
23
|
-
get pathsToModuleNameMapper() {
|
|
24
|
-
console.warn('ts-jest[main] (WARN) Replace any occurrences of "ts-jest/utils" with just "ts-jest".')
|
|
25
|
-
|
|
26
|
-
return pathsToModuleNameMapper
|
|
27
|
-
},
|
|
28
|
-
}
|