ts-jest 29.3.1 → 29.3.3
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 +19 -0
- package/README.md +1 -1
- package/dist/cli/config/init.js +103 -128
- package/dist/cli/config/migrate.js +113 -156
- package/dist/cli/help.js +14 -42
- package/dist/cli/helpers/presets.js +7 -8
- package/dist/cli/index.js +47 -101
- package/dist/config/paths-to-module-name-mapper.js +37 -61
- package/dist/constants.js +1 -5
- package/dist/index.js +2 -2
- package/dist/legacy/compiler/compiler-utils.js +5 -5
- package/dist/legacy/compiler/ts-compiler.js +200 -213
- package/dist/legacy/compiler/ts-jest-compiler.js +9 -9
- package/dist/legacy/config/config-set.js +281 -292
- package/dist/legacy/index.js +2 -4
- package/dist/legacy/ts-jest-transformer.d.ts +0 -3
- package/dist/legacy/ts-jest-transformer.js +152 -211
- package/dist/presets/all-presets.js +2 -2
- package/dist/presets/create-jest-preset.js +101 -139
- package/dist/transformers/hoist-jest.js +30 -43
- package/dist/transpilers/typescript/transpile-module.js +69 -98
- package/dist/types.js +1 -1
- package/dist/utils/backports.js +26 -28
- package/dist/utils/get-package-version.js +2 -2
- package/dist/utils/importer.js +53 -108
- package/dist/utils/json.js +2 -28
- package/dist/utils/jsonable-value.js +20 -27
- package/dist/utils/logger.js +11 -15
- package/dist/utils/memoize.js +11 -17
- package/dist/utils/messages.js +2 -3
- package/dist/utils/sha1.js +7 -11
- package/dist/utils/ts-error.js +19 -35
- package/package.json +20 -20
- package/tsconfig.base.json +20 -0
|
@@ -1,36 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.JsonableValue = void 0;
|
|
4
|
-
|
|
4
|
+
const json_1 = require("./json");
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
class JsonableValue {
|
|
7
|
+
_serialized;
|
|
8
|
+
_value;
|
|
9
|
+
constructor(value) {
|
|
8
10
|
this.value = value;
|
|
9
11
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this._value = value;
|
|
16
|
-
this._serialized = (0, json_1.stringify)(value);
|
|
17
|
-
},
|
|
18
|
-
enumerable: false,
|
|
19
|
-
configurable: true
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(JsonableValue.prototype, "serialized", {
|
|
22
|
-
get: function () {
|
|
23
|
-
return this._serialized;
|
|
24
|
-
},
|
|
25
|
-
enumerable: false,
|
|
26
|
-
configurable: true
|
|
27
|
-
});
|
|
28
|
-
JsonableValue.prototype.valueOf = function () {
|
|
12
|
+
set value(value) {
|
|
13
|
+
this._value = value;
|
|
14
|
+
this._serialized = (0, json_1.stringify)(value);
|
|
15
|
+
}
|
|
16
|
+
get value() {
|
|
29
17
|
return this._value;
|
|
30
|
-
}
|
|
31
|
-
|
|
18
|
+
}
|
|
19
|
+
get serialized() {
|
|
32
20
|
return this._serialized;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
}
|
|
22
|
+
valueOf() {
|
|
23
|
+
return this._value;
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return this._serialized;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
36
29
|
exports.JsonableValue = JsonableValue;
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rootLogger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_a),
|
|
16
|
-
targets: (_b = process.env.TS_JEST_LOG) !== null && _b !== void 0 ? _b : undefined,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
4
|
+
const bs_logger_1 = require("bs-logger");
|
|
5
|
+
const backports_1 = require("./backports");
|
|
6
|
+
const original = process.env.TS_JEST_LOG;
|
|
7
|
+
const buildOptions = () => ({
|
|
8
|
+
context: {
|
|
9
|
+
[bs_logger_1.LogContexts.package]: 'ts-jest',
|
|
10
|
+
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
|
11
|
+
version: require('../../package.json').version,
|
|
12
|
+
},
|
|
13
|
+
targets: process.env.TS_JEST_LOG ?? undefined,
|
|
14
|
+
});
|
|
19
15
|
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
|
20
16
|
(0, backports_1.backportTsJestDebugEnvVar)(exports.rootLogger);
|
|
21
17
|
// re-create the logger if the env var has been backported
|
package/dist/utils/memoize.js
CHANGED
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Memoize = Memoize;
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
|
|
5
|
+
const cacheProp = Symbol.for('[memoize]');
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
10
|
function Memoize(keyBuilder) {
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
return
|
|
12
|
+
return (_, propertyKey, descriptor) => {
|
|
13
13
|
if (descriptor.value != null) {
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || (
|
|
15
|
+
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
|
|
16
16
|
}
|
|
17
17
|
else if (descriptor.get != null) {
|
|
18
|
-
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (
|
|
18
|
+
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
function ensureCache(target, reset) {
|
|
25
|
-
if (reset === void 0) { reset = false; }
|
|
24
|
+
function ensureCache(target, reset = false) {
|
|
26
25
|
if (reset || !target[cacheProp]) {
|
|
27
26
|
Object.defineProperty(target, cacheProp, {
|
|
28
27
|
value: Object.create(null),
|
|
@@ -33,9 +32,8 @@ function ensureCache(target, reset) {
|
|
|
33
32
|
}
|
|
34
33
|
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
|
35
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
|
-
function ensureChildCache(target, key, reset) {
|
|
37
|
-
|
|
38
|
-
var dict = ensureCache(target);
|
|
35
|
+
function ensureChildCache(target, key, reset = false) {
|
|
36
|
+
const dict = ensureCache(target);
|
|
39
37
|
if (reset || !dict[key]) {
|
|
40
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
39
|
dict[key] = new Map();
|
|
@@ -49,17 +47,13 @@ func,
|
|
|
49
47
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
48
|
keyBuilder) {
|
|
51
49
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
return function () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
args[_i] = arguments[_i];
|
|
56
|
-
}
|
|
57
|
-
var cache = ensureChildCache(this, namespace);
|
|
58
|
-
var key = keyBuilder.apply(this, args);
|
|
50
|
+
return function (...args) {
|
|
51
|
+
const cache = ensureChildCache(this, namespace);
|
|
52
|
+
const key = keyBuilder.apply(this, args);
|
|
59
53
|
if (cache.has(key))
|
|
60
54
|
return cache.get(key);
|
|
61
55
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
|
|
56
|
+
const res = func.apply(this, args);
|
|
63
57
|
cache.set(key, res);
|
|
64
58
|
return res;
|
|
65
59
|
};
|
package/dist/utils/messages.js
CHANGED
|
@@ -6,10 +6,9 @@ exports.interpolate = interpolate;
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
function interpolate(msg, vars) {
|
|
10
|
-
if (vars === void 0) { vars = {}; }
|
|
9
|
+
function interpolate(msg, vars = {}) {
|
|
11
10
|
// eslint-disable-next-line no-useless-escape
|
|
12
|
-
return msg.replace(/\{\{([^\}]+)\}\}/g,
|
|
11
|
+
return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _));
|
|
13
12
|
}
|
|
14
13
|
exports.TsJestDiagnosticCodes = {
|
|
15
14
|
Generic: 151000,
|
package/dist/utils/sha1.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cache = void 0;
|
|
4
4
|
exports.sha1 = sha1;
|
|
5
|
-
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
@@ -11,14 +11,10 @@ exports.cache = Object.create(null);
|
|
|
11
11
|
/**
|
|
12
12
|
* @internal
|
|
13
13
|
*/
|
|
14
|
-
function sha1() {
|
|
15
|
-
|
|
16
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
17
|
-
data[_i] = arguments[_i];
|
|
18
|
-
}
|
|
19
|
-
var canCache = data.length === 1 && typeof data[0] === 'string';
|
|
14
|
+
function sha1(...data) {
|
|
15
|
+
const canCache = data.length === 1 && typeof data[0] === 'string';
|
|
20
16
|
// caching
|
|
21
|
-
|
|
17
|
+
let cacheKey;
|
|
22
18
|
if (canCache) {
|
|
23
19
|
cacheKey = data[0];
|
|
24
20
|
if (cacheKey in exports.cache) {
|
|
@@ -27,14 +23,14 @@ function sha1() {
|
|
|
27
23
|
}
|
|
28
24
|
// we use SHA1 because it's the fastest provided by node
|
|
29
25
|
// and we are not concerned about security here
|
|
30
|
-
|
|
31
|
-
data.forEach(
|
|
26
|
+
const hash = (0, crypto_1.createHash)('sha1');
|
|
27
|
+
data.forEach((item) => {
|
|
32
28
|
if (typeof item === 'string')
|
|
33
29
|
hash.update(item, 'utf8');
|
|
34
30
|
else
|
|
35
31
|
hash.update(item);
|
|
36
32
|
});
|
|
37
|
-
|
|
33
|
+
const res = hash.digest('hex').toString();
|
|
38
34
|
if (canCache) {
|
|
39
35
|
exports.cache[cacheKey] = res;
|
|
40
36
|
}
|
package/dist/utils/ts-error.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.TSError = exports.INSPECT_CUSTOM = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const make_error_1 = require("make-error");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
const messages_1 = require("./messages");
|
|
8
|
+
const logger = logger_1.rootLogger.child({ namespace: 'TSError' });
|
|
24
9
|
/**
|
|
25
10
|
* @internal
|
|
26
11
|
*/
|
|
@@ -30,24 +15,23 @@ exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
|
|
|
30
15
|
*
|
|
31
16
|
* @internal
|
|
32
17
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
class TSError extends make_error_1.BaseError {
|
|
19
|
+
diagnosticText;
|
|
20
|
+
diagnosticCodes;
|
|
21
|
+
name = 'TSError';
|
|
22
|
+
constructor(diagnosticText, diagnosticCodes) {
|
|
23
|
+
super((0, messages_1.interpolate)("{{diagnostics}}" /* Errors.UnableToCompileTypeScript */, {
|
|
37
24
|
diagnostics: diagnosticText.trim(),
|
|
38
|
-
}))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
logger.debug({ diagnosticCodes: diagnosticCodes, diagnosticText: diagnosticText }, 'created new TSError');
|
|
25
|
+
}));
|
|
26
|
+
this.diagnosticText = diagnosticText;
|
|
27
|
+
this.diagnosticCodes = diagnosticCodes;
|
|
28
|
+
logger.debug({ diagnosticCodes, diagnosticText }, 'created new TSError');
|
|
43
29
|
// ensure we blacklist any of our code
|
|
44
|
-
Object.defineProperty(
|
|
45
|
-
return _this;
|
|
30
|
+
Object.defineProperty(this, 'stack', { value: '' });
|
|
46
31
|
}
|
|
47
32
|
/* istanbul ignore next */
|
|
48
|
-
|
|
33
|
+
[exports.INSPECT_CUSTOM]() {
|
|
49
34
|
return this.diagnosticText;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}(make_error_1.BaseError));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
53
37
|
exports.TSError = TSError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "29.3.
|
|
3
|
+
"version": "29.3.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"build": "tsc -p tsconfig.build.json",
|
|
14
14
|
"postbuild": "node scripts/post-build.js",
|
|
15
15
|
"test": "jest -c=jest.config.ts",
|
|
16
|
-
"test-e2e-cjs": "jest -c=jest-e2e.config.
|
|
17
|
-
"test-e2e-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-e2e.config.
|
|
16
|
+
"test-e2e-cjs": "jest -c=jest-e2e-cjs.config.ts --no-cache",
|
|
17
|
+
"test-e2e-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-e2e-esm.config.ts --no-cache",
|
|
18
18
|
"test-examples": "node scripts/test-examples.js",
|
|
19
19
|
"lint": "eslint .",
|
|
20
20
|
"lint-fix": "eslint --fix .",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"json5": "^2.2.3",
|
|
59
59
|
"lodash.memoize": "^4.1.2",
|
|
60
60
|
"make-error": "^1.3.6",
|
|
61
|
-
"semver": "^7.7.
|
|
62
|
-
"type-fest": "^4.
|
|
61
|
+
"semver": "^7.7.2",
|
|
62
|
+
"type-fest": "^4.41.0",
|
|
63
63
|
"yargs-parser": "^21.1.1"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@commitlint/cli": "^19.8.
|
|
92
|
-
"@commitlint/config-angular": "^19.8.
|
|
93
|
-
"@eslint/compat": "^1.2.
|
|
91
|
+
"@commitlint/cli": "^19.8.1",
|
|
92
|
+
"@commitlint/config-angular": "^19.8.1",
|
|
93
|
+
"@eslint/compat": "^1.2.9",
|
|
94
94
|
"@eslint/eslintrc": "^3.3.1",
|
|
95
|
-
"@eslint/js": "^9.
|
|
95
|
+
"@eslint/js": "^9.26.0",
|
|
96
96
|
"@jest/globals": "^29.7.0",
|
|
97
97
|
"@jest/transform": "^29.7.0",
|
|
98
98
|
"@jest/types": "^29.6.3",
|
|
@@ -105,35 +105,35 @@
|
|
|
105
105
|
"@types/lodash.memoize": "^4.1.9",
|
|
106
106
|
"@types/lodash.set": "^4.3.9",
|
|
107
107
|
"@types/micromatch": "^4.0.9",
|
|
108
|
-
"@types/node": "20.17.
|
|
108
|
+
"@types/node": "20.17.47",
|
|
109
109
|
"@types/semver": "^7.7.0",
|
|
110
110
|
"@types/yargs": "^17.0.33",
|
|
111
111
|
"@types/yargs-parser": "21.0.3",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
113
|
-
"@typescript-eslint/parser": "^8.
|
|
112
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
113
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
114
114
|
"babel-jest": "^29.7.0",
|
|
115
115
|
"conventional-changelog-cli": "^5.0.0",
|
|
116
|
-
"esbuild": "~0.25.
|
|
117
|
-
"eslint": "^9.
|
|
118
|
-
"eslint-config-prettier": "^10.1.
|
|
116
|
+
"esbuild": "~0.25.4",
|
|
117
|
+
"eslint": "^9.26.0",
|
|
118
|
+
"eslint-config-prettier": "^10.1.5",
|
|
119
119
|
"eslint-plugin-import": "^2.31.0",
|
|
120
120
|
"eslint-plugin-jest": "^28.11.0",
|
|
121
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
121
|
+
"eslint-plugin-jsdoc": "^50.6.14",
|
|
122
122
|
"eslint-plugin-prettier": "^4.2.1",
|
|
123
123
|
"execa": "5.1.1",
|
|
124
124
|
"fs-extra": "^11.3.0",
|
|
125
125
|
"glob": "^10.2.6",
|
|
126
126
|
"glob-gitignore": "^1.0.15",
|
|
127
|
-
"globals": "^16.
|
|
127
|
+
"globals": "^16.1.0",
|
|
128
128
|
"husky": "^9.1.7",
|
|
129
129
|
"jest": "^29.7.0",
|
|
130
130
|
"js-yaml": "^4.1.0",
|
|
131
|
-
"lint-staged": "^15.5.
|
|
132
|
-
"memfs": "^4.17.
|
|
131
|
+
"lint-staged": "^15.5.2",
|
|
132
|
+
"memfs": "^4.17.1",
|
|
133
133
|
"prettier": "^2.8.8",
|
|
134
134
|
"rimraf": "^5.0.10",
|
|
135
135
|
"typescript": "~5.5.4",
|
|
136
|
-
"typescript-eslint": "^8.
|
|
136
|
+
"typescript-eslint": "^8.32.1"
|
|
137
137
|
},
|
|
138
138
|
"engines": {
|
|
139
139
|
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"downlevelIteration": true,
|
|
5
|
+
"experimentalDecorators": true,
|
|
6
|
+
"forceConsistentCasingInFileNames": true,
|
|
7
|
+
"noFallthroughCasesInSwitch": true,
|
|
8
|
+
"noUnusedLocals": true,
|
|
9
|
+
"noUnusedParameters": true,
|
|
10
|
+
"noImplicitReturns": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"checkJs": false,
|
|
15
|
+
"target": "ESNext",
|
|
16
|
+
"module": "NodeNext",
|
|
17
|
+
"moduleResolution": "NodeNext",
|
|
18
|
+
"lib": ["ESNext"]
|
|
19
|
+
}
|
|
20
|
+
}
|