ts-jest 29.3.2 → 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 +10 -0
- 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 +194 -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.js +134 -201
- 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 -2
- 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 +18 -18
- package/tsconfig.base.json +20 -0
- package/sonar-project.properties +0 -16
package/dist/cli/help.js
CHANGED
|
@@ -1,51 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.help = exports.run = void 0;
|
|
40
4
|
/**
|
|
41
5
|
* @internal
|
|
42
6
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
7
|
+
const run = async (_) => {
|
|
8
|
+
process.stdout.write(`
|
|
9
|
+
Usage:
|
|
10
|
+
ts-jest command [options] [...args]
|
|
11
|
+
|
|
12
|
+
Commands:
|
|
13
|
+
config:init Creates initial Jest configuration
|
|
14
|
+
config:migrate Migrates a given Jest configuration
|
|
15
|
+
help [command] Show this help, or help about a command
|
|
16
|
+
|
|
17
|
+
Example:
|
|
18
|
+
ts-jest help config:migrate
|
|
19
|
+
`);
|
|
20
|
+
};
|
|
49
21
|
exports.run = run;
|
|
50
22
|
/**
|
|
51
23
|
* @internal
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.jsWIthBabel = exports.jsWithTs = exports.defaults = exports.allPresets = void 0;
|
|
4
|
-
|
|
5
|
-
fullName
|
|
4
|
+
const definePreset = (fullName) => ({
|
|
5
|
+
fullName,
|
|
6
6
|
get name() {
|
|
7
7
|
return this.isDefault ? 'ts-jest' : fullName;
|
|
8
8
|
},
|
|
@@ -18,19 +18,18 @@ var definePreset = function (fullName) { return ({
|
|
|
18
18
|
.split('/')
|
|
19
19
|
.pop()
|
|
20
20
|
// eslint-disable-next-line no-useless-escape
|
|
21
|
-
.replace(/\-([a-z])/g,
|
|
21
|
+
.replace(/\-([a-z])/g, (_, l) => l.toUpperCase());
|
|
22
22
|
},
|
|
23
23
|
get value() {
|
|
24
|
-
return require(
|
|
24
|
+
return require(`../../../${fullName.replace(/^ts-jest\//, '')}/jest-preset`);
|
|
25
25
|
},
|
|
26
|
-
jsImport
|
|
27
|
-
|
|
28
|
-
return "const { ".concat(this.jsVarName, ": ").concat(varName, " } = require('ts-jest/presets')");
|
|
26
|
+
jsImport(varName = 'tsjPreset') {
|
|
27
|
+
return `const { ${this.jsVarName}: ${varName} } = require('ts-jest/presets')`;
|
|
29
28
|
},
|
|
30
29
|
get isDefault() {
|
|
31
30
|
return fullName === "ts-jest/presets/default" /* JestPresetNames.default */;
|
|
32
31
|
},
|
|
33
|
-
});
|
|
32
|
+
});
|
|
34
33
|
/** @internal */
|
|
35
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
35
|
exports.allPresets = {};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,89 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
|
-
var _a;
|
|
42
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
6
|
exports.processArgv = processArgv;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function cli(args) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
js:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return res;
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
// deprecated
|
|
69
|
-
if (parsedArgv.allowJs != null) {
|
|
70
|
-
if (parsedArgv.js)
|
|
71
|
-
throw new Error("The 'allowJs' and 'js' options cannot be set together.");
|
|
72
|
-
parsedArgv.js = parsedArgv.allowJs ? 'ts' : undefined;
|
|
73
|
-
}
|
|
74
|
-
command = parsedArgv._.shift();
|
|
75
|
-
isHelp = command === 'help';
|
|
76
|
-
if (isHelp)
|
|
77
|
-
command = parsedArgv._.shift();
|
|
78
|
-
if (!VALID_COMMANDS.includes(command))
|
|
79
|
-
command = 'help';
|
|
80
|
-
_a = require("./".concat(command.replace(/:/g, '/'))), run = _a.run, help = _a.help;
|
|
81
|
-
cmd = isHelp && command !== 'help' ? help : run;
|
|
82
|
-
return [2 /*return*/, cmd(parsedArgv, logger)];
|
|
83
|
-
});
|
|
7
|
+
const bs_logger_1 = require("bs-logger");
|
|
8
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const VALID_COMMANDS = ['help', 'config:migrate', 'config:init'];
|
|
11
|
+
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'cli', [bs_logger_1.LogContexts.application]: 'ts-jest' });
|
|
12
|
+
async function cli(args) {
|
|
13
|
+
const parsedArgv = (0, yargs_parser_1.default)(args, {
|
|
14
|
+
boolean: ['dry-run', 'jest-preset', 'allow-js', 'diff', 'babel', 'force', 'jsdom'],
|
|
15
|
+
string: ['tsconfig', 'js'],
|
|
16
|
+
count: ['verbose'],
|
|
17
|
+
alias: { verbose: ['v'] },
|
|
18
|
+
default: { jestPreset: true, verbose: 0 },
|
|
19
|
+
coerce: {
|
|
20
|
+
js(val) {
|
|
21
|
+
const res = val.trim().toLowerCase();
|
|
22
|
+
if (!['babel', 'ts'].includes(res))
|
|
23
|
+
throw new Error(`The 'js' option must be 'babel' or 'ts', given: '${val}'.`);
|
|
24
|
+
return res;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
84
27
|
});
|
|
28
|
+
// deprecated
|
|
29
|
+
if (parsedArgv.allowJs != null) {
|
|
30
|
+
if (parsedArgv.js)
|
|
31
|
+
throw new Error("The 'allowJs' and 'js' options cannot be set together.");
|
|
32
|
+
parsedArgv.js = parsedArgv.allowJs ? 'ts' : undefined;
|
|
33
|
+
}
|
|
34
|
+
let command = parsedArgv._.shift();
|
|
35
|
+
const isHelp = command === 'help';
|
|
36
|
+
if (isHelp)
|
|
37
|
+
command = parsedArgv._.shift();
|
|
38
|
+
if (!VALID_COMMANDS.includes(command))
|
|
39
|
+
command = 'help';
|
|
40
|
+
const { run, help } = require(`./${command.replace(/:/g, '/')}`);
|
|
41
|
+
const cmd = isHelp && command !== 'help' ? help : run;
|
|
42
|
+
return cmd(parsedArgv, logger);
|
|
85
43
|
}
|
|
86
|
-
|
|
44
|
+
const errorHasMessage = (err) => {
|
|
87
45
|
if (typeof err !== 'object' || err === null)
|
|
88
46
|
return false;
|
|
89
47
|
return 'message' in err;
|
|
@@ -91,27 +49,15 @@ var errorHasMessage = function (err) {
|
|
|
91
49
|
/**
|
|
92
50
|
* @internal
|
|
93
51
|
*/
|
|
94
|
-
function processArgv() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return [3 /*break*/, 3];
|
|
106
|
-
case 2:
|
|
107
|
-
err_1 = _a.sent();
|
|
108
|
-
if (errorHasMessage(err_1)) {
|
|
109
|
-
logger.fatal(err_1.message);
|
|
110
|
-
process.exit(1);
|
|
111
|
-
}
|
|
112
|
-
return [3 /*break*/, 3];
|
|
113
|
-
case 3: return [2 /*return*/];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
52
|
+
async function processArgv() {
|
|
53
|
+
try {
|
|
54
|
+
await cli(process.argv.slice(2));
|
|
55
|
+
process.exit(0);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (errorHasMessage(err)) {
|
|
59
|
+
logger.fatal(err.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
117
63
|
}
|
|
@@ -1,72 +1,48 @@
|
|
|
1
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
|
-
var _a;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.pathsToModuleNameMapper = void 0;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
const bs_logger_1 = require("bs-logger");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const messages_1 = require("../utils/messages");
|
|
19
7
|
// we don't need to escape all chars, so commented out is the real one
|
|
20
8
|
// const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
if (useESM) {
|
|
53
|
-
var esmPattern = "^".concat(escapeRegex(segments[0]), "(.*)").concat(escapeRegex(segments[1]), "\\.js$");
|
|
54
|
-
jestMap[esmPattern] = paths.length === 1 ? paths[0] : paths;
|
|
55
|
-
}
|
|
56
|
-
var cjsPattern = "^".concat(escapeRegex(segments[0]), "(.*)").concat(escapeRegex(segments[1]), "$");
|
|
57
|
-
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has more than one star (`*`)." /* Errors.NotMappingMultiStarPath */, { path: fromPath }));
|
|
9
|
+
const escapeRegex = (str) => str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
10
|
+
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'path-mapper' });
|
|
11
|
+
const pathsToModuleNameMapper = (mapping, { prefix = '', useESM = false } = {}) => {
|
|
12
|
+
const jestMap = {};
|
|
13
|
+
for (const fromPath of Object.keys(mapping)) {
|
|
14
|
+
const toPaths = mapping[fromPath];
|
|
15
|
+
// check that we have only one target path
|
|
16
|
+
if (toPaths.length === 0) {
|
|
17
|
+
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has no target." /* Errors.NotMappingPathWithEmptyMap */, { path: fromPath }));
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
// split with '*'
|
|
21
|
+
const segments = fromPath.split(/\*/g);
|
|
22
|
+
if (segments.length === 1) {
|
|
23
|
+
const paths = toPaths.map((target) => {
|
|
24
|
+
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
|
25
|
+
return `${enrichedPrefix}${target}`;
|
|
26
|
+
});
|
|
27
|
+
const cjsPattern = `^${escapeRegex(fromPath)}$`;
|
|
28
|
+
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
|
29
|
+
}
|
|
30
|
+
else if (segments.length === 2) {
|
|
31
|
+
const paths = toPaths.map((target) => {
|
|
32
|
+
const enrichedTarget = target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target;
|
|
33
|
+
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
|
34
|
+
return `${enrichedPrefix}${enrichedTarget.replace(/\*/g, '$1')}`;
|
|
35
|
+
});
|
|
36
|
+
if (useESM) {
|
|
37
|
+
const esmPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}\\.js$`;
|
|
38
|
+
jestMap[esmPattern] = paths.length === 1 ? paths[0] : paths;
|
|
61
39
|
}
|
|
40
|
+
const cjsPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}$`;
|
|
41
|
+
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
finally {
|
|
66
|
-
try {
|
|
67
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
43
|
+
else {
|
|
44
|
+
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has more than one star (`*`)." /* Errors.NotMappingMultiStarPath */, { path: fromPath }));
|
|
68
45
|
}
|
|
69
|
-
finally { if (e_1) throw e_1.error; }
|
|
70
46
|
}
|
|
71
47
|
if (useESM) {
|
|
72
48
|
jestMap['^(\\.{1,2}/.*)\\.js$'] = '$1';
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_JEST_TEST_MATCH = exports.JS_EXT_TO_TREAT_AS_ESM = exports.TS_EXT_TO_TREAT_AS_ESM = exports.ESM_JS_TRANSFORM_PATTERN = exports.JS_TRANSFORM_PATTERN = exports.ESM_TS_JS_TRANSFORM_PATTERN = exports.TS_JS_TRANSFORM_PATTERN = exports.ESM_TS_TRANSFORM_PATTERN = exports.TS_TRANSFORM_PATTERN = exports.JS_JSX_REGEX = exports.TS_TSX_REGEX = exports.JS_JSX_EXTENSIONS = exports.DECLARATION_TYPE_EXT = exports.LINE_FEED = void 0;
|
|
4
4
|
exports.LINE_FEED = '\n';
|
|
5
5
|
exports.DECLARATION_TYPE_EXT = '.d.ts';
|
|
6
6
|
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
|
|
@@ -20,7 +20,3 @@ exports.JS_EXT_TO_TREAT_AS_ESM = ['.jsx'];
|
|
|
20
20
|
* See https://jestjs.io/docs/en/configuration#testmatch-arraystring
|
|
21
21
|
*/
|
|
22
22
|
exports.DEFAULT_JEST_TEST_MATCH = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
exports.JEST_CONFIG_EJS_TEMPLATE = "/** @type {import('ts-jest').JestConfigWithTsJest} **/\n<%= exportKind %> {\n testEnvironment: \"<%= testEnvironment %>\",\n transform: {\n \"<%= transformPattern %>\": <%- transformValue %>,\n },\n};";
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
const ts_jest_transformer_1 = require("./legacy/ts-jest-transformer");
|
|
18
18
|
__exportStar(require("./config"), exports);
|
|
19
19
|
__exportStar(require("./constants"), exports);
|
|
20
20
|
__exportStar(require("./legacy/compiler"), exports);
|
|
@@ -25,7 +25,7 @@ __exportStar(require("./raw-compiler-options"), exports);
|
|
|
25
25
|
__exportStar(require("./utils"), exports);
|
|
26
26
|
__exportStar(require("./types"), exports);
|
|
27
27
|
exports.default = {
|
|
28
|
-
createTransformer
|
|
28
|
+
createTransformer(tsJestConfig) {
|
|
29
29
|
return new ts_jest_transformer_1.TsJestTransformer(tsJestConfig);
|
|
30
30
|
},
|
|
31
31
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SOURCE_MAPPING_PREFIX = void 0;
|
|
4
4
|
exports.updateOutput = updateOutput;
|
|
5
|
-
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
6
|
/**
|
|
7
7
|
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
|
|
8
8
|
*/
|
|
@@ -12,8 +12,8 @@ exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
|
|
12
12
|
*/
|
|
13
13
|
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
|
14
14
|
if (sourceMap) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
|
16
|
+
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`;
|
|
17
17
|
// sourceMappingURL= prefix is always at the end of compiledOutput, using lastIndexOf should be the safest way to substring
|
|
18
18
|
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) +
|
|
19
19
|
sourceMapContent);
|
|
@@ -23,8 +23,8 @@ function updateOutput(outputText, normalizedFileName, sourceMap) {
|
|
|
23
23
|
/**
|
|
24
24
|
* Update the source map contents for improved output.
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const updateSourceMap = (sourceMapText, normalizedFileName) => {
|
|
27
|
+
const sourceMap = JSON.parse(sourceMapText);
|
|
28
28
|
sourceMap.file = normalizedFileName;
|
|
29
29
|
sourceMap.sources = [normalizedFileName];
|
|
30
30
|
delete sourceMap.sourceRoot;
|