@depup/ts-jest 29.4.6-depup.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/.lintstagedrc +4 -0
- package/.ts-jest-digest +1 -0
- package/CHANGELOG.md +2025 -0
- package/CONTRIBUTING.md +121 -0
- package/LICENSE.md +21 -0
- package/README.md +33 -0
- package/TROUBLESHOOTING.md +3 -0
- package/changes.json +18 -0
- package/cli.js +3 -0
- package/dist/cli/config/init.d.ts +6 -0
- package/dist/cli/config/init.js +139 -0
- package/dist/cli/config/migrate.d.ts +1 -0
- package/dist/cli/config/migrate.js +177 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +25 -0
- package/dist/cli/helpers/presets.d.ts +1 -0
- package/dist/cli/helpers/presets.js +41 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +63 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +18 -0
- package/dist/config/paths-to-module-name-mapper.d.ts +9 -0
- package/dist/config/paths-to-module-name-mapper.js +52 -0
- package/dist/config/types.d.ts +2 -0
- package/dist/config/types.js +2 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +22 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +31 -0
- package/dist/legacy/compiler/compiler-utils.d.ts +8 -0
- package/dist/legacy/compiler/compiler-utils.js +32 -0
- package/dist/legacy/compiler/index.d.ts +2 -0
- package/dist/legacy/compiler/index.js +18 -0
- package/dist/legacy/compiler/ts-compiler.d.ts +27 -0
- package/dist/legacy/compiler/ts-compiler.js +434 -0
- package/dist/legacy/compiler/ts-jest-compiler.d.ts +8 -0
- package/dist/legacy/compiler/ts-jest-compiler.js +18 -0
- package/dist/legacy/config/config-set.d.ts +36 -0
- package/dist/legacy/config/config-set.js +622 -0
- package/dist/legacy/index.d.ts +6 -0
- package/dist/legacy/index.js +6 -0
- package/dist/legacy/ts-jest-transformer.d.ts +28 -0
- package/dist/legacy/ts-jest-transformer.js +293 -0
- package/dist/presets/all-presets.d.ts +15 -0
- package/dist/presets/all-presets.js +42 -0
- package/dist/presets/create-jest-preset.d.ts +18 -0
- package/dist/presets/create-jest-preset.js +180 -0
- package/dist/raw-compiler-options.d.ts +556 -0
- package/dist/raw-compiler-options.js +2 -0
- package/dist/transformers/hoist-jest.d.ts +9 -0
- package/dist/transformers/hoist-jest.js +111 -0
- package/dist/transpilers/typescript/transpile-module.d.ts +8 -0
- package/dist/transpilers/typescript/transpile-module.js +174 -0
- package/dist/types.d.ts +282 -0
- package/dist/types.js +3 -0
- package/dist/utils/backports.d.ts +1 -0
- package/dist/utils/backports.js +118 -0
- package/dist/utils/diagnostics.d.ts +5 -0
- package/dist/utils/diagnostics.js +8 -0
- package/dist/utils/get-package-version.d.ts +1 -0
- package/dist/utils/get-package-version.js +14 -0
- package/dist/utils/importer.d.ts +1 -0
- package/dist/utils/importer.js +146 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +16 -0
- package/dist/utils/jsonable-value.d.ts +10 -0
- package/dist/utils/jsonable-value.js +29 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/logger.js +20 -0
- package/dist/utils/memoize.d.ts +1 -0
- package/dist/utils/memoize.js +60 -0
- package/dist/utils/messages.d.ts +1 -0
- package/dist/utils/messages.js +21 -0
- package/dist/utils/normalize-slashes.d.ts +1 -0
- package/dist/utils/normalize-slashes.js +9 -0
- package/dist/utils/sha1.d.ts +1 -0
- package/dist/utils/sha1.js +38 -0
- package/dist/utils/ts-error.d.ts +1 -0
- package/dist/utils/ts-error.js +37 -0
- package/jest-preset.js +1 -0
- package/legacy.js +1 -0
- package/package.json +167 -0
- package/preprocessor.js +7 -0
- package/presets/default/jest-preset.js +1 -0
- package/presets/default-esm/jest-preset.js +1 -0
- package/presets/default-esm-legacy/jest-preset.js +1 -0
- package/presets/default-legacy/jest-preset.js +1 -0
- package/presets/index.d.ts +3 -0
- package/presets/index.js +3 -0
- package/presets/js-with-babel/jest-preset.js +1 -0
- package/presets/js-with-babel-esm/jest-preset.js +1 -0
- package/presets/js-with-babel-esm-legacy/jest-preset.js +1 -0
- package/presets/js-with-babel-legacy/jest-preset.js +1 -0
- package/presets/js-with-ts/jest-preset.js +1 -0
- package/presets/js-with-ts-esm/jest-preset.js +1 -0
- package/presets/js-with-ts-esm-legacy/jest-preset.js +1 -0
- package/presets/js-with-ts-legacy/jest-preset.js +1 -0
- package/tsconfig.base.json +20 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.importer = exports.Importer = void 0;
|
|
10
|
+
exports.__requireModule = __requireModule;
|
|
11
|
+
const logger_1 = require("./logger");
|
|
12
|
+
const memoize_1 = require("./memoize");
|
|
13
|
+
const messages_1 = require("./messages");
|
|
14
|
+
const logger = logger_1.rootLogger.child({ namespace: 'Importer' });
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
class Importer {
|
|
19
|
+
static get instance() {
|
|
20
|
+
logger.debug('creating Importer singleton');
|
|
21
|
+
return new Importer();
|
|
22
|
+
}
|
|
23
|
+
babelJest(why) {
|
|
24
|
+
return this._import(why, 'babel-jest');
|
|
25
|
+
}
|
|
26
|
+
babelCore(why) {
|
|
27
|
+
return this._import(why, '@babel/core');
|
|
28
|
+
}
|
|
29
|
+
typescript(why, which) {
|
|
30
|
+
return this._import(why, which);
|
|
31
|
+
}
|
|
32
|
+
esBuild(why) {
|
|
33
|
+
return this._import(why, 'esbuild');
|
|
34
|
+
}
|
|
35
|
+
tryThese(moduleName, ...fallbacks) {
|
|
36
|
+
let name;
|
|
37
|
+
let loaded;
|
|
38
|
+
const tries = [moduleName, ...fallbacks];
|
|
39
|
+
while ((name = tries.shift()) !== undefined) {
|
|
40
|
+
const req = requireWrapper(name);
|
|
41
|
+
// remove exports from what we're going to log
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
const contextReq = { ...req };
|
|
44
|
+
delete contextReq.exports;
|
|
45
|
+
if (req.exists) {
|
|
46
|
+
// module exists
|
|
47
|
+
loaded = req;
|
|
48
|
+
if (req.error) {
|
|
49
|
+
logger.error({ requireResult: contextReq }, `failed loading module '${name}'`, req.error.message);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.debug({ requireResult: contextReq }, 'loaded module', name);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// module does not exists in the path
|
|
58
|
+
logger.debug({ requireResult: contextReq }, `module '${name}' not found`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// return the loaded one, could be one that has been loaded, or one which has failed during load
|
|
62
|
+
// but not one which does not exists
|
|
63
|
+
return loaded;
|
|
64
|
+
}
|
|
65
|
+
tryTheseOr(moduleNames, missingResult, allowLoadError = false) {
|
|
66
|
+
const args = Array.isArray(moduleNames) ? moduleNames : [moduleNames];
|
|
67
|
+
const result = this.tryThese(...args);
|
|
68
|
+
if (!result)
|
|
69
|
+
return missingResult;
|
|
70
|
+
if (!result.error)
|
|
71
|
+
return result.exports;
|
|
72
|
+
if (allowLoadError)
|
|
73
|
+
return missingResult;
|
|
74
|
+
throw result.error;
|
|
75
|
+
}
|
|
76
|
+
_import(why, moduleName, { alternatives = [], installTip = moduleName } = {}) {
|
|
77
|
+
// try to load any of the alternative after trying main one
|
|
78
|
+
const res = this.tryThese(moduleName, ...alternatives);
|
|
79
|
+
// if we could load one, return it
|
|
80
|
+
if (res?.exists) {
|
|
81
|
+
if (!res.error)
|
|
82
|
+
return res.exports;
|
|
83
|
+
// it could not load because of a failure while importing, but it exists
|
|
84
|
+
throw new Error((0, messages_1.interpolate)("Loading module {{module}} failed with error: {{error}}" /* Errors.LoadingModuleFailed */, { module: res.given, error: res.error.message }));
|
|
85
|
+
}
|
|
86
|
+
// if it couldn't load, build a nice error message so the user can fix it by himself
|
|
87
|
+
const msg = alternatives.length ? "Unable to load any of these modules: {{module}}. {{reason}}. To fix it:\n{{fix}}" /* Errors.UnableToLoadAnyModule */ : "Unable to load the module {{module}}. {{reason}} To fix it:\n{{fix}}" /* Errors.UnableToLoadOneModule */;
|
|
88
|
+
const loadModule = [moduleName, ...alternatives].map((m) => `"${m}"`).join(', ');
|
|
89
|
+
if (typeof installTip === 'string') {
|
|
90
|
+
installTip = [{ module: installTip, label: `install "${installTip}"` }];
|
|
91
|
+
}
|
|
92
|
+
const fix = installTip
|
|
93
|
+
.map((tip) => ` ${installTip.length === 1 ? '↳' : '•'} ${(0, messages_1.interpolate)(messages_1.Helps.FixMissingModule, tip)}`)
|
|
94
|
+
.join('\n');
|
|
95
|
+
throw new Error((0, messages_1.interpolate)(msg, {
|
|
96
|
+
module: loadModule,
|
|
97
|
+
reason: why,
|
|
98
|
+
fix,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Importer = Importer;
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, memoize_1.Memoize)((...args) => args.join(':'))
|
|
105
|
+
], Importer.prototype, "tryThese", null);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, memoize_1.Memoize)()
|
|
108
|
+
], Importer, "instance", null);
|
|
109
|
+
/**
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
exports.importer = Importer.instance;
|
|
113
|
+
function requireWrapper(moduleName) {
|
|
114
|
+
let path;
|
|
115
|
+
let exists = false;
|
|
116
|
+
try {
|
|
117
|
+
path = resolveModule(moduleName);
|
|
118
|
+
exists = true;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { error: error, exists, given: moduleName };
|
|
122
|
+
}
|
|
123
|
+
const result = { exists, path, given: moduleName };
|
|
124
|
+
try {
|
|
125
|
+
result.exports = requireModule(path);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
try {
|
|
129
|
+
result.exports = requireModule(moduleName);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
result.error = error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
let requireModule = (mod) => require(mod);
|
|
138
|
+
let resolveModule = (mod) => require.resolve(mod, { paths: [process.cwd(), __dirname] });
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
// so that we can test easier
|
|
143
|
+
function __requireModule(localRequire, localResolve) {
|
|
144
|
+
requireModule = localRequire;
|
|
145
|
+
resolveModule = localResolve;
|
|
146
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
__exportStar(require("./json"), exports);
|
|
18
|
+
__exportStar(require("./jsonable-value"), exports);
|
|
19
|
+
__exportStar(require("./logger"), exports);
|
|
20
|
+
__exportStar(require("./diagnostics"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stringify = stringify;
|
|
7
|
+
exports.parse = parse;
|
|
8
|
+
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
|
9
|
+
const UNDEFINED = 'undefined';
|
|
10
|
+
function stringify(input) {
|
|
11
|
+
return input === undefined ? UNDEFINED : (0, fast_json_stable_stringify_1.default)(input);
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
function parse(input) {
|
|
15
|
+
return input === UNDEFINED ? undefined : JSON.parse(input);
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonableValue = void 0;
|
|
4
|
+
const json_1 = require("./json");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
class JsonableValue {
|
|
7
|
+
_serialized;
|
|
8
|
+
_value;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
set value(value) {
|
|
13
|
+
this._value = value;
|
|
14
|
+
this._serialized = (0, json_1.stringify)(value);
|
|
15
|
+
}
|
|
16
|
+
get value() {
|
|
17
|
+
return this._value;
|
|
18
|
+
}
|
|
19
|
+
get serialized() {
|
|
20
|
+
return this._serialized;
|
|
21
|
+
}
|
|
22
|
+
valueOf() {
|
|
23
|
+
return this._value;
|
|
24
|
+
}
|
|
25
|
+
toString() {
|
|
26
|
+
return this._serialized;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.JsonableValue = JsonableValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare let rootLogger: import("bs-logger").Logger;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rootLogger = void 0;
|
|
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
|
+
});
|
|
15
|
+
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
|
16
|
+
(0, backports_1.backportTsJestDebugEnvVar)(exports.rootLogger);
|
|
17
|
+
// re-create the logger if the env var has been backported
|
|
18
|
+
if (original !== process.env.TS_JEST_LOG) {
|
|
19
|
+
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Memoize = Memoize;
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const cacheProp = Symbol.for('[memoize]');
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
function Memoize(keyBuilder) {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
return (_, propertyKey, descriptor) => {
|
|
13
|
+
if (descriptor.value != null) {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
|
|
16
|
+
}
|
|
17
|
+
else if (descriptor.get != null) {
|
|
18
|
+
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
function ensureCache(target, reset = false) {
|
|
25
|
+
if (reset || !target[cacheProp]) {
|
|
26
|
+
Object.defineProperty(target, cacheProp, {
|
|
27
|
+
value: Object.create(null),
|
|
28
|
+
configurable: true,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return target[cacheProp];
|
|
32
|
+
}
|
|
33
|
+
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
function ensureChildCache(target, key, reset = false) {
|
|
36
|
+
const dict = ensureCache(target);
|
|
37
|
+
if (reset || !dict[key]) {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
dict[key] = new Map();
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
return dict[key];
|
|
43
|
+
}
|
|
44
|
+
function memoize(namespace,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
func,
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
keyBuilder) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
return function (...args) {
|
|
51
|
+
const cache = ensureChildCache(this, namespace);
|
|
52
|
+
const key = keyBuilder.apply(this, args);
|
|
53
|
+
if (cache.has(key))
|
|
54
|
+
return cache.get(key);
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
const res = func.apply(this, args);
|
|
57
|
+
cache.set(key, res);
|
|
58
|
+
return res;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Helps = void 0;
|
|
4
|
+
exports.interpolate = interpolate;
|
|
5
|
+
const diagnostics_1 = require("./diagnostics");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
exports.Helps = {
|
|
10
|
+
FixMissingModule: '{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)',
|
|
11
|
+
MigrateConfigUsingCLI: 'Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.',
|
|
12
|
+
UsingModernNodeResolution: `Using hybrid module kind (Node16/18/Next) is only supported in "isolatedModules: true". Please set "isolatedModules: true" in your tsconfig.json. To disable this message, you can set "diagnostics.ignoreCodes" to include ${diagnostics_1.TsJestDiagnosticCodes.ModernNodeModule} in your ts-jest config. See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/options/diagnostics`,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
function interpolate(msg, vars = {}) {
|
|
19
|
+
// eslint-disable-next-line no-useless-escape
|
|
20
|
+
return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _));
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cache = void 0;
|
|
4
|
+
exports.sha1 = sha1;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
// stores hashes made out of only one argument being a string
|
|
10
|
+
exports.cache = Object.create(null);
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
function sha1(...data) {
|
|
15
|
+
const canCache = data.length === 1 && typeof data[0] === 'string';
|
|
16
|
+
// caching
|
|
17
|
+
let cacheKey;
|
|
18
|
+
if (canCache) {
|
|
19
|
+
cacheKey = data[0];
|
|
20
|
+
if (cacheKey in exports.cache) {
|
|
21
|
+
return exports.cache[cacheKey];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// we use SHA1 because it's the fastest provided by node
|
|
25
|
+
// and we are not concerned about security here
|
|
26
|
+
const hash = (0, crypto_1.createHash)('sha1');
|
|
27
|
+
data.forEach((item) => {
|
|
28
|
+
if (typeof item === 'string')
|
|
29
|
+
hash.update(item, 'utf8');
|
|
30
|
+
else
|
|
31
|
+
hash.update(item);
|
|
32
|
+
});
|
|
33
|
+
const res = hash.digest('hex').toString();
|
|
34
|
+
if (canCache) {
|
|
35
|
+
exports.cache[cacheKey] = res;
|
|
36
|
+
}
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TSError = exports.INSPECT_CUSTOM = void 0;
|
|
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' });
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
|
|
13
|
+
/**
|
|
14
|
+
* TypeScript diagnostics error.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
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 */, {
|
|
24
|
+
diagnostics: diagnosticText.trim(),
|
|
25
|
+
}));
|
|
26
|
+
this.diagnosticText = diagnosticText;
|
|
27
|
+
this.diagnosticCodes = diagnosticCodes;
|
|
28
|
+
logger.debug({ diagnosticCodes, diagnosticText }, 'created new TSError');
|
|
29
|
+
// ensure we blacklist any of our code
|
|
30
|
+
Object.defineProperty(this, 'stack', { value: '' });
|
|
31
|
+
}
|
|
32
|
+
/* istanbul ignore next */
|
|
33
|
+
[exports.INSPECT_CUSTOM]() {
|
|
34
|
+
return this.diagnosticText;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.TSError = TSError;
|
package/jest-preset.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./presets').defaults
|
package/legacy.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/legacy')
|
package/package.json
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@depup/ts-jest",
|
|
3
|
+
"version": "29.4.6-depup.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ts-jest": "cli.js"
|
|
9
|
+
},
|
|
10
|
+
"description": "[DepUp] A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"prebuild": "rimraf --glob dist coverage *.tgz",
|
|
13
|
+
"build": "tsc -p tsconfig.build.json",
|
|
14
|
+
"postbuild": "node scripts/post-build.js",
|
|
15
|
+
"test": "jest -c=jest.config.ts",
|
|
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
|
+
"test-examples": "node scripts/test-examples.js",
|
|
19
|
+
"lint": "eslint .",
|
|
20
|
+
"lint-fix": "eslint --fix .",
|
|
21
|
+
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write",
|
|
22
|
+
"lint-prettier-ci": "prettier '**/*.{yml,yaml,md}' --check",
|
|
23
|
+
"doc": "cd website && npm run start",
|
|
24
|
+
"doc:build": "cd website && npm run build",
|
|
25
|
+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
|
26
|
+
"preversion": "npm run test",
|
|
27
|
+
"version": "npm run changelog && git add CHANGELOG.md"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/kulshekhar/ts-jest.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"depup",
|
|
35
|
+
"dependency-bumped",
|
|
36
|
+
"updated-deps",
|
|
37
|
+
"ts-jest",
|
|
38
|
+
"jest",
|
|
39
|
+
"typescript",
|
|
40
|
+
"sourcemap",
|
|
41
|
+
"react",
|
|
42
|
+
"testing"
|
|
43
|
+
],
|
|
44
|
+
"author": "Kulshekhar Kabra <kulshekhar@users.noreply.github.com> (https://github.com/kulshekhar)",
|
|
45
|
+
"contributors": [
|
|
46
|
+
"Huafu Gandon <huafu.gandon@gmail.com> (https://github.com/huafu)",
|
|
47
|
+
"Anh Pham <anhpnnd@gmail.com> (https://github.com/ahnpnl)",
|
|
48
|
+
"Gustav Wengel <gustavwengel@gmail.com> (https://github.com/GeeWee)"
|
|
49
|
+
],
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/kulshekhar/ts-jest/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://kulshekhar.github.io/ts-jest",
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"bs-logger": "^0.2.6",
|
|
57
|
+
"fast-json-stable-stringify": "^2.1.0",
|
|
58
|
+
"handlebars": "^4.7.8",
|
|
59
|
+
"json5": "^2.2.3",
|
|
60
|
+
"lodash.memoize": "^4.1.2",
|
|
61
|
+
"make-error": "^1.3.6",
|
|
62
|
+
"semver": "^7.7.4",
|
|
63
|
+
"type-fest": "^5.4.4",
|
|
64
|
+
"yargs-parser": "^22.0.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
68
|
+
"@jest/transform": "^29.0.0 || ^30.0.0",
|
|
69
|
+
"@jest/types": "^29.0.0 || ^30.0.0",
|
|
70
|
+
"babel-jest": "^29.0.0 || ^30.0.0",
|
|
71
|
+
"jest": "^29.0.0 || ^30.0.0",
|
|
72
|
+
"jest-util": "^29.0.0 || ^30.0.0",
|
|
73
|
+
"typescript": ">=4.3 <6"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"@babel/core": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@jest/transform": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@jest/types": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"babel-jest": {
|
|
86
|
+
"optional": true
|
|
87
|
+
},
|
|
88
|
+
"esbuild": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"jest-util": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"devDependencies": {
|
|
96
|
+
"@commitlint/cli": "^19.8.1",
|
|
97
|
+
"@commitlint/config-angular": "^19.8.1",
|
|
98
|
+
"@eslint/compat": "^1.4.1",
|
|
99
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
100
|
+
"@eslint/js": "^9.39.1",
|
|
101
|
+
"@jest/globals": "^30.2.0",
|
|
102
|
+
"@jest/transform": "^30.2.0",
|
|
103
|
+
"@jest/types": "^30.2.0",
|
|
104
|
+
"@types/babel__core": "^7.20.5",
|
|
105
|
+
"@types/fs-extra": "^11.0.4",
|
|
106
|
+
"@types/jest": "^29.5.14",
|
|
107
|
+
"@types/js-yaml": "^4.0.9",
|
|
108
|
+
"@types/lodash.camelcase": "^4.3.9",
|
|
109
|
+
"@types/lodash.memoize": "^4.1.9",
|
|
110
|
+
"@types/lodash.set": "^4.3.9",
|
|
111
|
+
"@types/micromatch": "^4.0.10",
|
|
112
|
+
"@types/node": "20.19.25",
|
|
113
|
+
"@types/semver": "^7.7.1",
|
|
114
|
+
"@types/yargs": "^17.0.35",
|
|
115
|
+
"@types/yargs-parser": "21.0.3",
|
|
116
|
+
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
|
117
|
+
"@typescript-eslint/parser": "^8.48.0",
|
|
118
|
+
"babel-jest": "^30.2.0",
|
|
119
|
+
"conventional-changelog-angular": "^8.1.0",
|
|
120
|
+
"conventional-changelog": "^7.1.1",
|
|
121
|
+
"esbuild": "~0.27.0",
|
|
122
|
+
"eslint": "^9.39.1",
|
|
123
|
+
"eslint-config-prettier": "^10.1.8",
|
|
124
|
+
"eslint-plugin-import": "^2.32.0",
|
|
125
|
+
"eslint-plugin-jest": "^28.14.0",
|
|
126
|
+
"eslint-plugin-jsdoc": "^50.8.0",
|
|
127
|
+
"eslint-plugin-prettier": "^4.2.5",
|
|
128
|
+
"execa": "5.1.1",
|
|
129
|
+
"fast-glob": "^3.3.3",
|
|
130
|
+
"fs-extra": "^11.3.2",
|
|
131
|
+
"globals": "^16.5.0",
|
|
132
|
+
"husky": "^9.1.7",
|
|
133
|
+
"jest": "^30.2.0",
|
|
134
|
+
"js-yaml": "^4.1.1",
|
|
135
|
+
"lint-staged": "^15.5.2",
|
|
136
|
+
"memfs": "^4.51.0",
|
|
137
|
+
"prettier": "^2.8.8",
|
|
138
|
+
"rimraf": "^5.0.10",
|
|
139
|
+
"ts-node": "^10.9.2",
|
|
140
|
+
"typescript": "~5.9.3",
|
|
141
|
+
"typescript-eslint": "^8.48.0"
|
|
142
|
+
},
|
|
143
|
+
"engines": {
|
|
144
|
+
"node": "^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0"
|
|
145
|
+
},
|
|
146
|
+
"depup": {
|
|
147
|
+
"changes": {
|
|
148
|
+
"semver": {
|
|
149
|
+
"from": "^7.7.3",
|
|
150
|
+
"to": "^7.7.4"
|
|
151
|
+
},
|
|
152
|
+
"type-fest": {
|
|
153
|
+
"from": "^4.41.0",
|
|
154
|
+
"to": "^5.4.4"
|
|
155
|
+
},
|
|
156
|
+
"yargs-parser": {
|
|
157
|
+
"from": "^21.1.1",
|
|
158
|
+
"to": "^22.0.0"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"depsUpdated": 3,
|
|
162
|
+
"originalPackage": "ts-jest",
|
|
163
|
+
"originalVersion": "29.4.6",
|
|
164
|
+
"processedAt": "2026-03-17T16:39:42.819Z",
|
|
165
|
+
"smokeTest": "passed"
|
|
166
|
+
}
|
|
167
|
+
}
|
package/preprocessor.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
console.warn(
|
|
2
|
+
'ts-jest[main] (WARN) Replace any occurrences of "ts-jest/dist/preprocessor.js" or ' +
|
|
3
|
+
' "<rootDir>/node_modules/ts-jest/preprocessor.js"' +
|
|
4
|
+
' in the \'transform\' section of your Jest config with just "ts-jest".'
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
module.exports = require('./dist')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').defaults
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').defaultsESM
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').defaultsESMLegacy
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').defaultsLegacy
|
package/presets/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').jsWithBabel
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').jsWithBabelESM
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('..').jsWithBabelESMLegacy
|