ts-jest 27.1.3 → 28.0.0-next.1
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 +69 -0
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +5 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +11 -5
- package/dist/{compiler → legacy/compiler}/index.d.ts +0 -1
- package/dist/{compiler → legacy/compiler}/index.js +5 -2
- package/dist/{compiler → legacy/compiler}/ts-compiler.d.ts +5 -4
- package/dist/{compiler → legacy/compiler}/ts-compiler.js +17 -9
- package/dist/{compiler → legacy/compiler}/ts-jest-compiler.d.ts +4 -3
- package/dist/{compiler → legacy/compiler}/ts-jest-compiler.js +0 -0
- package/dist/{config → legacy/config}/config-set.d.ts +2 -2
- package/dist/{config → legacy/config}/config-set.js +15 -14
- 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 +7 -5
- 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 +18 -19
- package/dist/compiler/compiler-utils.d.ts +0 -2
- package/dist/compiler/compiler-utils.js +0 -24
- package/dist/transformers/path-mapping.d.ts +0 -5
- package/dist/transformers/path-mapping.js +0 -129
- 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
|
+
7b476847710fa2fbf7328253469857e80f9cf85d
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
+
# [28.0.0-next.1](https://github.com/kulshekhar/ts-jest/compare/v28.0.0-next.0...v28.0.0-next.1) (2022-04-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* mark `ConfigSet` as legacy ([#3456](https://github.com/kulshekhar/ts-jest/issues/3456)) ([a986729](https://github.com/kulshekhar/ts-jest/commit/a98672977a679d1ed882605a3e71ed405432ffdc))
|
|
7
|
+
* mark `TsCompiler` and `TsJestCompiler` as legacy ([#3457](https://github.com/kulshekhar/ts-jest/issues/3457)) ([0f2fe30](https://github.com/kulshekhar/ts-jest/commit/0f2fe306762d8549bd29737becd4aed14a650427))
|
|
8
|
+
* remove `path-mapping` AST transformer ([#3455](https://github.com/kulshekhar/ts-jest/issues/3455)) ([f566869](https://github.com/kulshekhar/ts-jest/commit/f5668698f8fab78b3008d936aa5001f134f530e2))
|
|
9
|
+
* set Jest peer dependencies to v28 ([#3454](https://github.com/kulshekhar/ts-jest/issues/3454)) ([1e880ff](https://github.com/kulshekhar/ts-jest/commit/1e880fffe82bca231d1d23f6508f4ab4bc31e03e))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* `path-mapping` AST transformer is no longer shipped in `ts-jest` v28. Please use an alternative one like https://github.com/LeDDGroup/typescript-transform-paths instead.
|
|
15
|
+
* Any imports `ts-jest/dist/compiler/ts-compiler` should change to `ts-jest/dist/legacy/compiler/ts-compiler`
|
|
16
|
+
* Any imports `ts-jest/dist/compiler/ts-jest-compiler` should change to `ts-jest/dist/legacy/compiler/ts-jest-compiler`
|
|
17
|
+
* Any imports `ts-jest/dist/config/config-set` should change to `ts-jest/dist/legacy/config/config-set
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# [28.0.0-next.0](https://github.com/kulshekhar/ts-jest/compare/v27.1.3...v28.0.0-next.0) (2022-04-24)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **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))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **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))
|
|
32
|
+
* **core:** remove `mocked` testing util ([#3333](https://github.com/kulshekhar/ts-jest/issues/3333)) ([2d9017d](https://github.com/kulshekhar/ts-jest/commit/2d9017ddfea39f45aa991876b314d1dbe4a36aad))
|
|
33
|
+
* **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))
|
|
34
|
+
* mark `TsJestTransformer` as legacy ([#3451](https://github.com/kulshekhar/ts-jest/issues/3451)) ([b090179](https://github.com/kulshekhar/ts-jest/commit/b0901799adc519959a954dba5e7b8fc8b97a9665))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### BREAKING CHANGES
|
|
38
|
+
|
|
39
|
+
* Minimum support TypeScript version is now **4.3** since Jest 28 requires it
|
|
40
|
+
* Jest 28 is required
|
|
41
|
+
* **core:** Any imports `ts-jest/utils` should be replaced with `ts-jest`.
|
|
42
|
+
* **core:** Starting from Jest 27.4, `mocked` has been integrated into Jest repo.
|
|
43
|
+
* **core:** Support for Node.js v10 has been removed as Jest drops support for it
|
|
44
|
+
* All presets now will they are preserved for refactored codes. If you wish to use the old codes, please do the following
|
|
45
|
+
*
|
|
46
|
+
```diff
|
|
47
|
+
// jest.config.js
|
|
48
|
+
module.exports = {
|
|
49
|
+
// [...]
|
|
50
|
+
- preset: 'ts-jest', // or 'js-with-babel'/'js-with-ts'
|
|
51
|
+
+ transform: {
|
|
52
|
+
'^.+\\.tsx?$': 'ts-jest/legacy' // or '^.+\\.[tj]sx?$': 'ts-jest' to use legacy codes
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## [27.1.4](https://github.com/kulshekhar/ts-jest/compare/v27.1.3...v27.1.4) (2022-03-24)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* **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)
|
|
65
|
+
* 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)
|
|
66
|
+
* 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)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
1
70
|
## [27.1.3](https://github.com/kulshekhar/ts-jest/compare/v27.1.2...v27.1.3) (2022-01-14)
|
|
2
71
|
|
|
3
72
|
|
package/dist/config/index.d.ts
CHANGED
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];
|
|
@@ -10,5 +14,4 @@ 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("./config-set"), exports);
|
|
14
17
|
__exportStar(require("./paths-to-module-name-mapper"), exports);
|
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
|
-
export * from './compiler';
|
|
4
|
+
export * from './legacy/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
|
-
__exportStar(require("./compiler"), exports);
|
|
20
|
+
__exportStar(require("./legacy/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
|
};
|
|
@@ -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,7 +1,8 @@
|
|
|
1
|
+
import type { TransformedSource } from '@jest/transform';
|
|
1
2
|
import { Logger } from 'bs-logger';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
|
|
4
|
+
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript } from '../../types';
|
|
5
|
+
import type { ConfigSet } from '../config/config-set';
|
|
5
6
|
export declare class TsCompiler implements TsCompilerInstance {
|
|
6
7
|
readonly configSet: ConfigSet;
|
|
7
8
|
readonly runtimeCacheFS: StringMap;
|
|
@@ -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
|
}
|
|
@@ -54,10 +54,9 @@ exports.TsCompiler = void 0;
|
|
|
54
54
|
var path_1 = require("path");
|
|
55
55
|
var bs_logger_1 = require("bs-logger");
|
|
56
56
|
var lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
|
57
|
-
var constants_1 = require("
|
|
58
|
-
var utils_1 = require("
|
|
59
|
-
var messages_1 = require("
|
|
60
|
-
var compiler_utils_1 = require("./compiler-utils");
|
|
57
|
+
var constants_1 = require("../../constants");
|
|
58
|
+
var utils_1 = require("../../utils");
|
|
59
|
+
var messages_1 = require("../../utils/messages");
|
|
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) {
|
|
@@ -264,7 +273,6 @@ var TsCompiler = (function () {
|
|
|
264
273
|
var hit = this._isFileInCache(fileName);
|
|
265
274
|
if (!hit) {
|
|
266
275
|
this._fileVersionCache.set(fileName, 1);
|
|
267
|
-
this._fileContentCache.set(fileName, contents);
|
|
268
276
|
shouldIncrementProjectVersion = true;
|
|
269
277
|
}
|
|
270
278
|
else {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '
|
|
1
|
+
import type { TransformedSource } from '@jest/transform';
|
|
2
|
+
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../../types';
|
|
3
|
+
import type { ConfigSet } from '../config/config-set';
|
|
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
|
}
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Logger } from 'bs-logger';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
import type { RawCompilerOptions } from '
|
|
4
|
-
import type { ProjectConfigTsJest, TsJestAstTransformer, TTypeScript } from '
|
|
3
|
+
import type { RawCompilerOptions } from '../../raw-compiler-options';
|
|
4
|
+
import type { ProjectConfigTsJest, TsJestAstTransformer, TTypeScript } from '../../types';
|
|
5
5
|
export declare class ConfigSet {
|
|
6
6
|
readonly parentLogger?: Logger | undefined;
|
|
7
7
|
readonly tsJestDigest: string;
|
|
@@ -57,15 +57,15 @@ var path_1 = require("path");
|
|
|
57
57
|
var bs_logger_1 = require("bs-logger");
|
|
58
58
|
var jest_util_1 = require("jest-util");
|
|
59
59
|
var json5_1 = __importDefault(require("json5"));
|
|
60
|
-
var constants_1 = require("
|
|
61
|
-
var utils_1 = require("
|
|
62
|
-
var backports_1 = require("
|
|
63
|
-
var importer_1 = require("
|
|
64
|
-
var messages_1 = require("
|
|
65
|
-
var normalize_slashes_1 = require("
|
|
66
|
-
var sha1_1 = require("
|
|
67
|
-
var ts_error_1 = require("
|
|
68
|
-
exports.MY_DIGEST = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '
|
|
60
|
+
var constants_1 = require("../../constants");
|
|
61
|
+
var utils_1 = require("../../utils");
|
|
62
|
+
var backports_1 = require("../../utils/backports");
|
|
63
|
+
var importer_1 = require("../../utils/importer");
|
|
64
|
+
var messages_1 = require("../../utils/messages");
|
|
65
|
+
var normalize_slashes_1 = require("../../utils/normalize-slashes");
|
|
66
|
+
var sha1_1 = require("../../utils/sha1");
|
|
67
|
+
var ts_error_1 = require("../../utils/ts-error");
|
|
68
|
+
exports.MY_DIGEST = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../../.ts-jest-digest'), 'utf8');
|
|
69
69
|
exports.IGNORE_DIAGNOSTIC_CODES = [
|
|
70
70
|
6059,
|
|
71
71
|
18002,
|
|
@@ -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;
|
|
@@ -231,7 +232,7 @@ var ConfigSet = (function () {
|
|
|
231
232
|
this.parsedTsConfig = this._getAndResolveTsConfig(typeof tsconfigOpt === 'object' ? tsconfigOpt : undefined, configFilePath);
|
|
232
233
|
this.raiseDiagnostics(this.parsedTsConfig.errors, configFilePath);
|
|
233
234
|
this.logger.debug({ tsconfig: this.parsedTsConfig }, 'normalized typescript config via ts-jest option');
|
|
234
|
-
this.resolvedTransformers.before = [require('
|
|
235
|
+
this.resolvedTransformers.before = [require('../../transformers/hoist-jest')];
|
|
235
236
|
var astTransformers = options.astTransformers;
|
|
236
237
|
if (astTransformers) {
|
|
237
238
|
var resolveTransformerFunc_1 = function (transformerPath) {
|
|
@@ -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],
|
|
@@ -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 type {
|
|
3
|
-
import { ConfigSet } from './config';
|
|
4
|
-
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest } from './types';
|
|
2
|
+
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest } from '../types';
|
|
3
|
+
import { ConfigSet } from './config/config-set';
|
|
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 constants_1 = require("../constants");
|
|
82
|
+
var utils_1 = require("../utils");
|
|
83
|
+
var importer_1 = require("../utils/importer");
|
|
84
|
+
var messages_1 = require("../utils/messages");
|
|
85
|
+
var sha1_1 = require("../utils/sha1");
|
|
86
|
+
var version_checkers_1 = require("../utils/version-checkers");
|
|
81
87
|
var compiler_1 = require("./compiler");
|
|
82
|
-
var
|
|
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");
|
|
88
|
+
var config_set_1 = require("./config/config-set");
|
|
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);
|
|
@@ -148,38 +151,80 @@ var TsJestTransformer = (function () {
|
|
|
148
151
|
return configSet;
|
|
149
152
|
};
|
|
150
153
|
TsJestTransformer.prototype._createConfigSet = function (config) {
|
|
151
|
-
return new
|
|
154
|
+
return new config_set_1.ConfigSet(config);
|
|
152
155
|
};
|
|
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,8 +1,9 @@
|
|
|
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
|
-
import type { ConfigSet } from './config';
|
|
6
|
+
import type { ConfigSet } from './legacy/config/config-set';
|
|
6
7
|
import type { RawCompilerOptions } from './raw-compiler-options';
|
|
7
8
|
declare module '@jest/types' {
|
|
8
9
|
namespace 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 <29"),
|
|
11
|
+
typescript: createVersionChecker('typescript', ">=4.3 <5"),
|
|
12
|
+
babelJest: createVersionChecker('babel-jest', ">=28.0.0 <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.1",
|
|
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",
|
|
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",
|
|
67
|
+
"jest": "^28.0.0",
|
|
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": "
|
|
92
|
+
"@commitlint/cli": "16.x",
|
|
94
93
|
"@commitlint/config-angular": "^16.0.0",
|
|
95
|
-
"@jest/transform": "^
|
|
96
|
-
"@jest/types": "^
|
|
94
|
+
"@jest/transform": "^28.0.0",
|
|
95
|
+
"@jest/types": "^28.0.0",
|
|
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.27",
|
|
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",
|
|
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
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type * as _ts from 'typescript';
|
|
2
|
-
import type { TsCompilerInstance } from '../types';
|
|
3
|
-
export declare const version = 2;
|
|
4
|
-
export declare const name = "path-mapping";
|
|
5
|
-
export declare function factory({ configSet, }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.factory = exports.name = exports.version = void 0;
|
|
15
|
-
var path_1 = require("path");
|
|
16
|
-
var bs_logger_1 = require("bs-logger");
|
|
17
|
-
exports.version = 2;
|
|
18
|
-
exports.name = 'path-mapping';
|
|
19
|
-
var isBaseDir = function (base, dir) { var _a; return !((_a = (0, path_1.relative)(base, dir)) === null || _a === void 0 ? void 0 : _a.startsWith('.')); };
|
|
20
|
-
function factory(_a) {
|
|
21
|
-
var _b;
|
|
22
|
-
var configSet = _a.configSet;
|
|
23
|
-
var logger = configSet.logger.child({ namespace: exports.name });
|
|
24
|
-
logger.warn('path-mapping AST transformer is deprecated and will be removed in `ts-jest` v28. Please use an alternative one, like https://github.com/LeDDGroup/typescript-transform-paths instead');
|
|
25
|
-
var ts = configSet.compilerModule;
|
|
26
|
-
var tsFactory = ts.factory ? ts.factory : ts;
|
|
27
|
-
var compilerOptions = configSet.parsedTsConfig.options;
|
|
28
|
-
var rootDirs = (_b = compilerOptions.rootDirs) === null || _b === void 0 ? void 0 : _b.filter(path_1.isAbsolute);
|
|
29
|
-
var isDynamicImport = function (node) {
|
|
30
|
-
return ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;
|
|
31
|
-
};
|
|
32
|
-
var isRequire = function (node) {
|
|
33
|
-
return ts.isCallExpression(node) &&
|
|
34
|
-
ts.isIdentifier(node.expression) &&
|
|
35
|
-
node.expression.text === 'require' &&
|
|
36
|
-
ts.isStringLiteral(node.arguments[0]) &&
|
|
37
|
-
node.arguments.length === 1;
|
|
38
|
-
};
|
|
39
|
-
var createVisitor = function (ctx, sf) {
|
|
40
|
-
var fileName = sf.fileName;
|
|
41
|
-
var fileDir = (0, path_1.normalize)((0, path_1.dirname)(fileName));
|
|
42
|
-
var rewritePath = function (importPath) {
|
|
43
|
-
var e_1, _a;
|
|
44
|
-
var p = importPath;
|
|
45
|
-
var resolvedModule = ts.resolveModuleName(importPath, fileName, compilerOptions, ts.sys).resolvedModule;
|
|
46
|
-
if (resolvedModule) {
|
|
47
|
-
var resolvedFileName = resolvedModule.resolvedFileName;
|
|
48
|
-
var filePath = fileDir;
|
|
49
|
-
var modulePath = (0, path_1.dirname)(resolvedFileName);
|
|
50
|
-
if (rootDirs) {
|
|
51
|
-
var fileRootDir = '';
|
|
52
|
-
var moduleRootDir = '';
|
|
53
|
-
try {
|
|
54
|
-
for (var rootDirs_1 = __values(rootDirs), rootDirs_1_1 = rootDirs_1.next(); !rootDirs_1_1.done; rootDirs_1_1 = rootDirs_1.next()) {
|
|
55
|
-
var rootDir = rootDirs_1_1.value;
|
|
56
|
-
if (isBaseDir(rootDir, resolvedFileName) && rootDir.length > moduleRootDir.length)
|
|
57
|
-
moduleRootDir = rootDir;
|
|
58
|
-
if (isBaseDir(rootDir, fileName) && rootDir.length > fileRootDir.length)
|
|
59
|
-
fileRootDir = rootDir;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
63
|
-
finally {
|
|
64
|
-
try {
|
|
65
|
-
if (rootDirs_1_1 && !rootDirs_1_1.done && (_a = rootDirs_1.return)) _a.call(rootDirs_1);
|
|
66
|
-
}
|
|
67
|
-
finally { if (e_1) throw e_1.error; }
|
|
68
|
-
}
|
|
69
|
-
if (fileRootDir && moduleRootDir) {
|
|
70
|
-
filePath = (0, path_1.relative)(fileRootDir, filePath);
|
|
71
|
-
modulePath = (0, path_1.relative)(moduleRootDir, modulePath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
p = (0, path_1.normalize)((0, path_1.join)((0, path_1.relative)(filePath, modulePath), (0, path_1.basename)(resolvedFileName)));
|
|
75
|
-
p = p.startsWith('.') ? p : "./".concat(p);
|
|
76
|
-
}
|
|
77
|
-
return p;
|
|
78
|
-
};
|
|
79
|
-
var visitor = function (node) {
|
|
80
|
-
var rewrittenPath;
|
|
81
|
-
var newNode = ts.getMutableClone(node);
|
|
82
|
-
if (isDynamicImport(node) || isRequire(node)) {
|
|
83
|
-
rewrittenPath = rewritePath(node.arguments[0].text);
|
|
84
|
-
var argumentArrays = tsFactory.createNodeArray([tsFactory.createStringLiteral(rewrittenPath)]);
|
|
85
|
-
return ts.factory
|
|
86
|
-
? ts.factory.updateCallExpression(node, node.expression, node.typeArguments, argumentArrays)
|
|
87
|
-
: ts.updateCall(node, node.expression, node.typeArguments, argumentArrays);
|
|
88
|
-
}
|
|
89
|
-
if (ts.isExternalModuleReference(node) && ts.isStringLiteral(node.expression)) {
|
|
90
|
-
rewrittenPath = rewritePath(node.expression.text);
|
|
91
|
-
return tsFactory.updateExternalModuleReference(newNode, tsFactory.createStringLiteral(rewrittenPath));
|
|
92
|
-
}
|
|
93
|
-
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
94
|
-
rewrittenPath = rewritePath(node.moduleSpecifier.text);
|
|
95
|
-
return +ts.versionMajorMinor >= 4.5
|
|
96
|
-
? tsFactory.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, tsFactory.createStringLiteral(rewrittenPath), node.assertClause)
|
|
97
|
-
:
|
|
98
|
-
tsFactory.updateImportDeclaration(node, node.decorators, node.modifiers, node.importClause, tsFactory.createStringLiteral(rewrittenPath));
|
|
99
|
-
}
|
|
100
|
-
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
101
|
-
rewrittenPath = rewritePath(node.moduleSpecifier.text);
|
|
102
|
-
var stringLiteralNode = tsFactory.createStringLiteral(rewrittenPath);
|
|
103
|
-
if (ts.factory) {
|
|
104
|
-
return +ts.versionMajorMinor >= 4.5
|
|
105
|
-
? ts.factory.updateExportDeclaration(node, node.decorators, node.modifiers, node.isTypeOnly, node.exportClause, stringLiteralNode, node.assertClause)
|
|
106
|
-
:
|
|
107
|
-
ts.factory.updateExportDeclaration(node, node.decorators, node.modifiers, node.isTypeOnly, node.exportClause, stringLiteralNode);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
return ts.updateExportDeclaration(node, node.decorators, node.modifiers, node.exportClause, stringLiteralNode, node.isTypeOnly);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (ts.isImportTypeNode(node) &&
|
|
114
|
-
ts.isLiteralTypeNode(node.argument) &&
|
|
115
|
-
ts.isStringLiteral(node.argument.literal)) {
|
|
116
|
-
rewrittenPath = rewritePath(node.argument.literal.text);
|
|
117
|
-
var importArguments = tsFactory.createLiteralTypeNode(tsFactory.createStringLiteral(rewrittenPath));
|
|
118
|
-
return tsFactory.updateImportTypeNode(node, importArguments, node.qualifier, node.typeArguments, node.isTypeOf);
|
|
119
|
-
}
|
|
120
|
-
return ts.visitEachChild(node, visitor, ctx);
|
|
121
|
-
};
|
|
122
|
-
return visitor;
|
|
123
|
-
};
|
|
124
|
-
return function (ctx) {
|
|
125
|
-
var _a;
|
|
126
|
-
return logger.wrap((_a = {}, _a[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.debug, _a.call = null, _a), 'visitSourceFileNode(): path mapping', function (sf) { return ts.visitNode(sf, createVisitor(ctx, sf)); });
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
exports.factory = factory;
|
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
|
-
}
|