ts-jest 27.0.1 → 27.0.5
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 +51 -4
- package/TROUBLESHOOTING.md +37 -3
- package/dist/cli/config/init.js +1 -0
- package/dist/compiler/ts-compiler.js +8 -9
- package/dist/config/config-set.js +19 -8
- package/dist/config/paths-to-module-name-mapper.js +2 -1
- package/dist/transformers/hoist-jest.d.ts +2 -1
- package/dist/transformers/hoist-jest.js +3 -1
- package/dist/transformers/path-mapping.d.ts +2 -0
- package/dist/transformers/path-mapping.js +3 -1
- package/dist/ts-jest-transformer.js +2 -5
- package/dist/utils/backports.js +7 -0
- package/package.json +21 -18
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
df3ae8b1c1562a3bb93465ae542aa416874eb4e7
|
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
## [27.0.
|
|
1
|
+
## [27.0.5](https://github.com/kulshekhar/ts-jest/compare/v27.0.4...v27.0.5) (2021-08-14)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
* **cli:**
|
|
7
|
-
* **
|
|
8
|
-
*
|
|
6
|
+
* **cli:** add migration `tsConfig` option for `ts-jest` config options ([#2794](https://github.com/kulshekhar/ts-jest/issues/2794)) ([781710b](https://github.com/kulshekhar/ts-jest/commit/781710bf6b84853fffbb02543062a726fe1ad9c2)), closes [#2764](https://github.com/kulshekhar/ts-jest/issues/2764)
|
|
7
|
+
* **cli:** fix `config:init` genarate invalid type comment ([#2773](https://github.com/kulshekhar/ts-jest/issues/2773)) ([ede8a20](https://github.com/kulshekhar/ts-jest/commit/ede8a2061e20b717c0d56e4d81a3cd0ec7db8b1a)), closes [#2772](https://github.com/kulshekhar/ts-jest/issues/2772)
|
|
8
|
+
* **config:** handle `./` in tsconfig `paths` for `pathsToModuleNameMapper` ([#2797](https://github.com/kulshekhar/ts-jest/issues/2797)) ([42ff5e4](https://github.com/kulshekhar/ts-jest/commit/42ff5e469fb5d315b92e85eee105e5a040949c01)), closes [#2709](https://github.com/kulshekhar/ts-jest/issues/2709)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Code Refactoring
|
|
12
|
+
|
|
13
|
+
* use native `Buffer.from` and `mkdird` ([#2774](https://github.com/kulshekhar/ts-jest/issues/2774)) ([4869660](https://github.com/kulshekhar/ts-jest/commit/4869660e3917deb063745c5acaf079123d6d2ca8))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [27.0.4](https://github.com/kulshekhar/ts-jest/compare/v27.0.3...v27.0.4) (2021-07-21)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* add `@types/jest` as optional `peerDependencies` to solve yarn 2 ([#2756](https://github.com/kulshekhar/ts-jest/issues/2756)) ([5fbf43e](https://github.com/kulshekhar/ts-jest/commit/5fbf43e64691d5146add1da4690a14b3095c4234))
|
|
23
|
+
* add `babel-jest` as optional `peerDependencies` to solve yarn 2 ([#2751](https://github.com/kulshekhar/ts-jest/issues/2751)) ([8bede2e](https://github.com/kulshekhar/ts-jest/commit/8bede2e57546a18999b96871069f1f94a3ecf3c1))
|
|
24
|
+
* **config:** include AST transformer's `name` and `version` into cache key ([#2755](https://github.com/kulshekhar/ts-jest/issues/2755)) ([310fb9a](https://github.com/kulshekhar/ts-jest/commit/310fb9a1d7b40a8274d6fb93745e66a6da891a75)), closes [#2753](https://github.com/kulshekhar/ts-jest/issues/2753)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* link jest config types on `npx ts-jest:init` ([#2742](https://github.com/kulshekhar/ts-jest/issues/2742)) ([f51ba05](https://github.com/kulshekhar/ts-jest/commit/f51ba0507568ba8a5dece48c159d7857a2ed61d6))
|
|
30
|
+
* set env var `TS_JEST` to allow detecting of `ts-jest` ([#2717](https://github.com/kulshekhar/ts-jest/issues/2717)) ([56c137a](https://github.com/kulshekhar/ts-jest/commit/56c137a3c1906f49cb0b9e044fa8e233707cbaa4)), closes [#2716](https://github.com/kulshekhar/ts-jest/issues/2716)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [27.0.3](https://github.com/kulshekhar/ts-jest/compare/v27.0.2...v27.0.3) (2021-06-06)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* revert `exports` field to support all node versions ([#2658](https://github.com/kulshekhar/ts-jest/issues/2658)) ([132c8ba](https://github.com/kulshekhar/ts-jest/commit/132c8ba85c3e61b7d9ede0dc9730580b79618ab7))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* emit ESM codes if using ESM mode with Babel ([#2661](https://github.com/kulshekhar/ts-jest/issues/2661)) ([9b55404](https://github.com/kulshekhar/ts-jest/commit/9b55404a8dfc760238e19786da98a2edf043b9da)), closes [#2650](https://github.com/kulshekhar/ts-jest/issues/2650)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## [27.0.2](https://github.com/kulshekhar/ts-jest/compare/v27.0.1...v27.0.2) (2021-05-30)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* **compiler:** add empty string file content to compiler cache ([#2633](https://github.com/kulshekhar/ts-jest/issues/2633)) ([0feb556](https://github.com/kulshekhar/ts-jest/commit/0feb5560a588f87d1d989bf521859fba0fda20fe)), closes [#2625](https://github.com/kulshekhar/ts-jest/issues/2625)
|
|
54
|
+
* **config:** `exclude` should only exclude files which match glob values ([#2637](https://github.com/kulshekhar/ts-jest/issues/2637)) ([c5ce979](https://github.com/kulshekhar/ts-jest/commit/c5ce97902c1b84dc354f270a4f596a6f5f634611)), closes [#2634](https://github.com/kulshekhar/ts-jest/issues/2634)
|
|
9
55
|
|
|
10
56
|
|
|
11
57
|
|
|
@@ -15,6 +61,7 @@
|
|
|
15
61
|
### Bug Fixes
|
|
16
62
|
|
|
17
63
|
* **cli:** keep `testMatch` if old jest config contains it ([#2618](https://github.com/kulshekhar/ts-jest/issues/2618)) ([c568f49](https://github.com/kulshekhar/ts-jest/commit/c568f49907fb5559ba1e8c67f1ec5d5eb4af920a)), closes [#2616](https://github.com/kulshekhar/ts-jest/issues/2616)
|
|
64
|
+
* **compiler:** make sure `isolatedModules: false` use updated compiler options ([#2628](https://github.com/kulshekhar/ts-jest/issues/2628)) ([348e30f](https://github.com/kulshekhar/ts-jest/commit/348e30f426803efc51ecba26ab42619938fcb5af)), closes [#2629](https://github.com/kulshekhar/ts-jest/issues/2629)
|
|
18
65
|
* add missing export `presets` ([#2624](https://github.com/kulshekhar/ts-jest/issues/2624)) ([0ea025e](https://github.com/kulshekhar/ts-jest/commit/0ea025ebb456d3a31671e31fac0b401c2734a2b1)), closes [#2623](https://github.com/kulshekhar/ts-jest/issues/2623)
|
|
19
66
|
|
|
20
67
|
|
package/TROUBLESHOOTING.md
CHANGED
|
@@ -10,7 +10,7 @@ Cannot find module "" from ""
|
|
|
10
10
|
|
|
11
11
|
- Check if `rootDir` is referenced correctly. If not add this on your existing jest configuration.
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```javascript
|
|
14
14
|
module.exports = {
|
|
15
15
|
...
|
|
16
16
|
roots: ["<rootDir>"]
|
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
|
19
19
|
|
|
20
20
|
- Check if module directories are included on your jest configuration. If not add this on your existing jest configuration.
|
|
21
21
|
|
|
22
|
-
```
|
|
22
|
+
```javascript
|
|
23
23
|
module.exports = {
|
|
24
24
|
...
|
|
25
25
|
moduleDirectories: ["node_modules","<module-directory>"],
|
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
|
29
29
|
|
|
30
30
|
- Check if module name is properly mapped and can be referenced by jest. If not, you can define moduleNameMapper for your jest configuration.
|
|
31
31
|
|
|
32
|
-
```
|
|
32
|
+
```javascript
|
|
33
33
|
module.exports = {
|
|
34
34
|
...
|
|
35
35
|
moduleNameMapper: {
|
|
@@ -39,3 +39,37 @@ module.exports = {
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
- Check github folder names if its identical to you local folder names. Sometimes github never updates your folder names even if you rename it locally. If this happens rename your folders via github or use this command `git mv <source> <destination>` and commit changes.
|
|
42
|
+
|
|
43
|
+
## Transform (node)-module explicitly
|
|
44
|
+
|
|
45
|
+
### PROBLEM
|
|
46
|
+
|
|
47
|
+
SyntaxError: Cannot use import statement outside a module
|
|
48
|
+
|
|
49
|
+
### SOLUTION
|
|
50
|
+
|
|
51
|
+
One of the node modules hasn't the correct syntax for Jests execution step. It needs to
|
|
52
|
+
be transformed first.
|
|
53
|
+
|
|
54
|
+
There is a good chance that the error message shows which module is affected:
|
|
55
|
+
|
|
56
|
+
```shell
|
|
57
|
+
SyntaxError: Cannot use import statement outside a module
|
|
58
|
+
> 22 | import Component from "../../node_modules/some-module/lib";
|
|
59
|
+
| ^
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
In this case **some-module** is the problem and needs to be transformed.
|
|
63
|
+
By adding the following line to the configuration file it will tell Jest which modules
|
|
64
|
+
shouldnt be ignored during the transformation step:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
module.exports = {
|
|
68
|
+
...
|
|
69
|
+
transformIgnorePatterns: ["node_modules/(?!(some-module|another-module))"]
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**some-module** and **another-module** will be transformed.
|
|
74
|
+
|
|
75
|
+
For more information see [here](https://stackoverflow.com/questions/63389757/jest-unit-test-syntaxerror-cannot-use-import-statement-outside-a-module) and [here](https://stackoverflow.com/questions/52035066/how-to-write-jest-transformignorepatterns).
|
package/dist/cli/config/init.js
CHANGED
|
@@ -119,6 +119,7 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
|
|
|
119
119
|
if (!jestPreset) {
|
|
120
120
|
content.push(preset.jsImport('tsjPreset') + ";", '');
|
|
121
121
|
}
|
|
122
|
+
content.push("/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */");
|
|
122
123
|
content.push('module.exports = {');
|
|
123
124
|
if (jestPreset) {
|
|
124
125
|
content.push(" preset: '" + preset.name + "',");
|
|
@@ -51,7 +51,6 @@ var path_1 = require("path");
|
|
|
51
51
|
var bs_logger_1 = require("bs-logger");
|
|
52
52
|
var memoize_1 = __importDefault(require("lodash/memoize"));
|
|
53
53
|
var constants_1 = require("../constants");
|
|
54
|
-
var json_1 = require("../utils/json");
|
|
55
54
|
var logger_1 = require("../utils/logger");
|
|
56
55
|
var messages_1 = require("../utils/messages");
|
|
57
56
|
var compiler_utils_1 = require("./compiler-utils");
|
|
@@ -107,7 +106,9 @@ var TsCompiler = (function () {
|
|
|
107
106
|
var moduleKind = this._initialCompilerOptions.module;
|
|
108
107
|
var esModuleInterop = this._initialCompilerOptions.esModuleInterop;
|
|
109
108
|
var allowSyntheticDefaultImports = this._initialCompilerOptions.allowSyntheticDefaultImports;
|
|
110
|
-
|
|
109
|
+
var currentModuleKind = this._compilerOptions.module;
|
|
110
|
+
if ((this.configSet.babelJestTransformer || (!this.configSet.babelJestTransformer && options.supportsStaticESM)) &&
|
|
111
|
+
this.configSet.useESM) {
|
|
111
112
|
moduleKind =
|
|
112
113
|
!moduleKind ||
|
|
113
114
|
(moduleKind &&
|
|
@@ -124,7 +125,7 @@ var TsCompiler = (function () {
|
|
|
124
125
|
esModuleInterop: esModuleInterop, module: moduleKind });
|
|
125
126
|
if (this._languageService) {
|
|
126
127
|
this._logger.debug({ fileName: fileName }, 'getCompiledOutput(): compiling using language service');
|
|
127
|
-
this._updateMemoryCache(fileContent, fileName);
|
|
128
|
+
this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
|
|
128
129
|
var output = this._languageService.getEmitOutput(fileName);
|
|
129
130
|
this._doTypeChecking(fileName, options.depGraphs, options.watchMode);
|
|
130
131
|
if (output.emitSkipped) {
|
|
@@ -196,7 +197,7 @@ var TsCompiler = (function () {
|
|
|
196
197
|
_this._logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
|
197
198
|
if (!hit) {
|
|
198
199
|
var fileContent = (_d = (_b = (_a = _this._fileContentCache.get(normalizedFileName)) !== null && _a !== void 0 ? _a : _this._runtimeCacheFS.get(normalizedFileName)) !== null && _b !== void 0 ? _b : (_c = _this._cachedReadFile) === null || _c === void 0 ? void 0 : _c.call(_this, normalizedFileName)) !== null && _d !== void 0 ? _d : undefined;
|
|
199
|
-
if (fileContent) {
|
|
200
|
+
if (fileContent !== undefined) {
|
|
200
201
|
_this._fileContentCache.set(normalizedFileName, fileContent);
|
|
201
202
|
_this._fileVersionCache.set(normalizedFileName, 1);
|
|
202
203
|
}
|
|
@@ -253,7 +254,8 @@ var TsCompiler = (function () {
|
|
|
253
254
|
this._fileVersionCache.has(fileName) &&
|
|
254
255
|
this._fileVersionCache.get(fileName) !== 0);
|
|
255
256
|
};
|
|
256
|
-
TsCompiler.prototype._updateMemoryCache = function (contents, fileName) {
|
|
257
|
+
TsCompiler.prototype._updateMemoryCache = function (contents, fileName, isModuleKindTheSame) {
|
|
258
|
+
if (isModuleKindTheSame === void 0) { isModuleKindTheSame = true; }
|
|
257
259
|
this._logger.debug({ fileName: fileName }, 'updateMemoryCache: update memory cache for language service');
|
|
258
260
|
var shouldIncrementProjectVersion = false;
|
|
259
261
|
var hit = this._isFileInCache(fileName);
|
|
@@ -269,13 +271,10 @@ var TsCompiler = (function () {
|
|
|
269
271
|
this._fileContentCache.set(fileName, contents);
|
|
270
272
|
shouldIncrementProjectVersion = true;
|
|
271
273
|
}
|
|
272
|
-
if (!this._parsedTsConfig.fileNames.includes(fileName)) {
|
|
274
|
+
if (!this._parsedTsConfig.fileNames.includes(fileName) || !isModuleKindTheSame) {
|
|
273
275
|
shouldIncrementProjectVersion = true;
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
|
-
if (json_1.stringify(this._compilerOptions) !== json_1.stringify(this._initialCompilerOptions)) {
|
|
277
|
-
shouldIncrementProjectVersion = true;
|
|
278
|
-
}
|
|
279
278
|
if (shouldIncrementProjectVersion)
|
|
280
279
|
this._projectVersion++;
|
|
281
280
|
};
|
|
@@ -207,9 +207,9 @@ var ConfigSet = (function () {
|
|
|
207
207
|
throws: diagnosticsOpt,
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
this.
|
|
210
|
+
this._shouldIgnoreDiagnosticsForFile = this._diagnostics.exclude.length
|
|
211
211
|
? jest_util_1.globsToMatcher(this._diagnostics.exclude)
|
|
212
|
-
: function () { return
|
|
212
|
+
: function () { return false; };
|
|
213
213
|
this.logger.debug({ diagnostics: this._diagnostics }, 'normalized diagnostics config via ts-jest option');
|
|
214
214
|
var tsconfigOpt = options.tsconfig;
|
|
215
215
|
var configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined;
|
|
@@ -219,13 +219,23 @@ var ConfigSet = (function () {
|
|
|
219
219
|
this.resolvedTransformers.before = [require('../transformers/hoist-jest')];
|
|
220
220
|
var astTransformers = options.astTransformers;
|
|
221
221
|
if (astTransformers) {
|
|
222
|
+
var resolveTransformerFunc_1 = function (transformerPath) {
|
|
223
|
+
var transformerFunc = require(transformerPath);
|
|
224
|
+
if (!transformerFunc.version) {
|
|
225
|
+
_this.logger.warn("The AST transformer {{file}} must have an `export const version = <your_transformer_version>`", { file: transformerPath });
|
|
226
|
+
}
|
|
227
|
+
if (!transformerFunc.name) {
|
|
228
|
+
_this.logger.warn("The AST transformer {{file}} must have an `export const name = <your_transformer_name>`", { file: transformerPath });
|
|
229
|
+
}
|
|
230
|
+
return transformerFunc;
|
|
231
|
+
};
|
|
222
232
|
var resolveTransformers = function (transformers) {
|
|
223
233
|
return transformers.map(function (transformer) {
|
|
224
234
|
if (typeof transformer === 'string') {
|
|
225
|
-
return
|
|
235
|
+
return resolveTransformerFunc_1(_this.resolvePath(transformer, { nodeResolve: true }));
|
|
226
236
|
}
|
|
227
237
|
else {
|
|
228
|
-
return __assign(__assign({},
|
|
238
|
+
return __assign(__assign({}, resolveTransformerFunc_1(_this.resolvePath(transformer.path, { nodeResolve: true }))), { options: transformer.options });
|
|
229
239
|
}
|
|
230
240
|
});
|
|
231
241
|
};
|
|
@@ -253,14 +263,15 @@ var ConfigSet = (function () {
|
|
|
253
263
|
version: this.compilerModule.version,
|
|
254
264
|
digest: this.tsJestDigest,
|
|
255
265
|
babelConfig: this.babelConfig,
|
|
256
|
-
compilerModule: this.compilerModule,
|
|
257
266
|
tsconfig: {
|
|
258
267
|
options: this.parsedTsConfig.options,
|
|
259
268
|
raw: this.parsedTsConfig.raw,
|
|
260
269
|
},
|
|
261
270
|
isolatedModules: this.isolatedModules,
|
|
262
271
|
diagnostics: this._diagnostics,
|
|
263
|
-
transformers: this.resolvedTransformers
|
|
272
|
+
transformers: Object.values(this.resolvedTransformers)
|
|
273
|
+
.reduce(function (prevVal, currentVal) { return __spreadArray(__spreadArray([], __read(prevVal)), [currentVal]); })
|
|
274
|
+
.map(function (transformer) { return transformer.name + "-" + transformer.version; }),
|
|
264
275
|
}));
|
|
265
276
|
if (!this._jestCfg.cache) {
|
|
266
277
|
this.logger.debug('file caching disabled');
|
|
@@ -397,8 +408,8 @@ var ConfigSet = (function () {
|
|
|
397
408
|
ConfigSet.prototype.shouldReportDiagnostics = function (filePath) {
|
|
398
409
|
var fileExtension = path_1.extname(filePath);
|
|
399
410
|
return constants_1.JS_JSX_EXTENSIONS.includes(fileExtension)
|
|
400
|
-
? this.parsedTsConfig.options.checkJs && this.
|
|
401
|
-
: this.
|
|
411
|
+
? this.parsedTsConfig.options.checkJs && !this._shouldIgnoreDiagnosticsForFile(filePath)
|
|
412
|
+
: !this._shouldIgnoreDiagnosticsForFile(filePath);
|
|
402
413
|
};
|
|
403
414
|
ConfigSet.prototype._createTsError = function (diagnostics) {
|
|
404
415
|
var _this = this;
|
|
@@ -42,8 +42,9 @@ var pathsToModuleNameMapper = function (mapping, _a) {
|
|
|
42
42
|
}
|
|
43
43
|
else if (segments.length === 2) {
|
|
44
44
|
var paths = toPaths.map(function (target) {
|
|
45
|
+
var enrichedTarget = target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target;
|
|
45
46
|
var enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? prefix + "/" : prefix;
|
|
46
|
-
return "" + enrichedPrefix +
|
|
47
|
+
return "" + enrichedPrefix + enrichedTarget.replace(/\*/g, '$1');
|
|
47
48
|
});
|
|
48
49
|
pattern = "^" + escapeRegex(segments[0]) + "(.*)" + escapeRegex(segments[1]) + "$";
|
|
49
50
|
jestMap[pattern] = paths.length === 1 ? paths[0] : paths;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const version = 1;
|
|
2
|
+
export declare const name = "hoist-jest";
|
|
@@ -32,8 +32,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.factory = void 0;
|
|
35
|
+
exports.factory = exports.name = exports.version = void 0;
|
|
36
36
|
var bs_logger_1 = require("bs-logger");
|
|
37
|
+
exports.version = 1;
|
|
38
|
+
exports.name = 'hoist-jest';
|
|
37
39
|
var HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock', 'deepUnmock'];
|
|
38
40
|
var JEST_GLOBALS_MODULE_NAME = '@jest/globals';
|
|
39
41
|
var JEST_GLOBAL_NAME = 'jest';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type * as _ts from 'typescript';
|
|
2
2
|
import type { TsCompilerInstance } from '../types';
|
|
3
|
+
export declare const version = 1;
|
|
4
|
+
export declare const name = "hoist-jest";
|
|
3
5
|
export declare function factory({ configSet, }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|
|
@@ -22,9 +22,11 @@ var __values = (this && this.__values) || function(o) {
|
|
|
22
22
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.factory = void 0;
|
|
25
|
+
exports.factory = exports.name = exports.version = void 0;
|
|
26
26
|
var path_1 = require("path");
|
|
27
27
|
var bs_logger_1 = require("bs-logger");
|
|
28
|
+
exports.version = 1;
|
|
29
|
+
exports.name = 'hoist-jest';
|
|
28
30
|
var isBaseDir = function (base, dir) { var _a; return !((_a = path_1.relative(base, dir)) === null || _a === void 0 ? void 0 : _a.startsWith('.')); };
|
|
29
31
|
function factory(_a) {
|
|
30
32
|
var _b;
|
|
@@ -31,14 +31,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
31
31
|
to[j] = from[i];
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
35
|
exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
|
|
39
36
|
var fs_1 = require("fs");
|
|
40
37
|
var path_1 = require("path");
|
|
41
|
-
var mkdirp_1 = __importDefault(require("mkdirp"));
|
|
42
38
|
var ts_jest_compiler_1 = require("./compiler/ts-jest-compiler");
|
|
43
39
|
var config_set_1 = require("./config/config-set");
|
|
44
40
|
var constants_1 = require("./constants");
|
|
@@ -59,6 +55,7 @@ var TsJestTransformer = (function () {
|
|
|
59
55
|
this.getCacheKey = this.getCacheKey.bind(this);
|
|
60
56
|
this.process = this.process.bind(this);
|
|
61
57
|
this._logger.debug('created new transformer');
|
|
58
|
+
process.env.TS_JEST = '1';
|
|
62
59
|
}
|
|
63
60
|
TsJestTransformer.prototype._configsFor = function (transformOptions) {
|
|
64
61
|
var config = transformOptions.config, cacheFS = transformOptions.cacheFS;
|
|
@@ -209,7 +206,7 @@ var TsJestTransformer = (function () {
|
|
|
209
206
|
TsJestTransformer.prototype._getFsCachedResolvedModules = function (configSet) {
|
|
210
207
|
var cacheDir = configSet.tsCacheDir;
|
|
211
208
|
if (!configSet.isolatedModules && cacheDir) {
|
|
212
|
-
|
|
209
|
+
fs_1.mkdirSync(cacheDir, { recursive: true });
|
|
213
210
|
this._tsResolvedModulesCachePath = path_1.join(cacheDir, sha1_1.sha1('ts-jest-resolved-modules', exports.CACHE_KEY_EL_SEPARATOR));
|
|
214
211
|
try {
|
|
215
212
|
var cachedTSResolvedModules = fs_1.readFileSync(this._tsResolvedModulesCachePath, 'utf-8');
|
package/dist/utils/backports.js
CHANGED
|
@@ -56,6 +56,13 @@ var backportJestConfig = function (logger, config) {
|
|
|
56
56
|
}
|
|
57
57
|
delete tsJest.tsConfigFile;
|
|
58
58
|
}
|
|
59
|
+
if ('tsConfig' in tsJest) {
|
|
60
|
+
warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig');
|
|
61
|
+
if (tsJest.tsConfig) {
|
|
62
|
+
mergeTsJest.tsconfig = tsJest.tsConfig;
|
|
63
|
+
}
|
|
64
|
+
delete tsJest.tsConfig;
|
|
65
|
+
}
|
|
59
66
|
if ('enableTsDiagnostics' in tsJest) {
|
|
60
67
|
warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics');
|
|
61
68
|
if (tsJest.enableTsDiagnostics) {
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": "./dist/index.js",
|
|
8
|
-
"./dist/*": "./dist/*.js",
|
|
9
|
-
"./jest-preset": "./jest-preset.js",
|
|
10
|
-
"./presets": "./presets/index.js",
|
|
11
|
-
"./utils": "./utils/index.js",
|
|
12
|
-
"./package.json": "./package.json"
|
|
13
|
-
},
|
|
14
6
|
"bin": {
|
|
15
7
|
"ts-jest": "cli.js"
|
|
16
8
|
},
|
|
@@ -65,20 +57,32 @@
|
|
|
65
57
|
"homepage": "https://kulshekhar.github.io/ts-jest",
|
|
66
58
|
"dependencies": {
|
|
67
59
|
"bs-logger": "0.x",
|
|
68
|
-
"buffer-from": "1.x",
|
|
69
60
|
"fast-json-stable-stringify": "2.x",
|
|
70
61
|
"jest-util": "^27.0.0",
|
|
71
62
|
"json5": "2.x",
|
|
72
63
|
"lodash": "4.x",
|
|
73
64
|
"make-error": "1.x",
|
|
74
|
-
"mkdirp": "1.x",
|
|
75
65
|
"semver": "7.x",
|
|
76
66
|
"yargs-parser": "20.x"
|
|
77
67
|
},
|
|
78
68
|
"peerDependencies": {
|
|
69
|
+
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
70
|
+
"@types/jest": "^27.0.0",
|
|
71
|
+
"babel-jest": ">=27.0.0 <28",
|
|
79
72
|
"jest": "^27.0.0",
|
|
80
73
|
"typescript": ">=3.8 <5.0"
|
|
81
74
|
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"babel-jest": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
"@babel/core": {
|
|
80
|
+
"optional": true
|
|
81
|
+
},
|
|
82
|
+
"@types/jest": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
82
86
|
"husky": {
|
|
83
87
|
"hooks": {
|
|
84
88
|
"pre-commit": "lint-staged",
|
|
@@ -87,20 +91,18 @@
|
|
|
87
91
|
}
|
|
88
92
|
},
|
|
89
93
|
"devDependencies": {
|
|
90
|
-
"@commitlint/cli": "
|
|
91
|
-
"@commitlint/config-angular": "^
|
|
94
|
+
"@commitlint/cli": "13.x",
|
|
95
|
+
"@commitlint/config-angular": "^13.1.0",
|
|
92
96
|
"@jest/transform": "^27.0.0",
|
|
93
97
|
"@jest/types": "^27.0.0",
|
|
94
98
|
"@types/babel__core": "7.x",
|
|
95
|
-
"@types/buffer-from": "latest",
|
|
96
99
|
"@types/cross-spawn": "latest",
|
|
97
100
|
"@types/fs-extra": "latest",
|
|
98
101
|
"@types/jest": "latest",
|
|
99
102
|
"@types/js-yaml": "latest",
|
|
100
103
|
"@types/lodash": "4.x",
|
|
101
104
|
"@types/micromatch": "4.x",
|
|
102
|
-
"@types/
|
|
103
|
-
"@types/node": "14.14.43",
|
|
105
|
+
"@types/node": "16.6.1",
|
|
104
106
|
"@types/node-fetch": "^2.5.8",
|
|
105
107
|
"@types/react": "17.x",
|
|
106
108
|
"@types/semver": "latest",
|
|
@@ -119,6 +121,7 @@
|
|
|
119
121
|
"eslint-plugin-prettier": "latest",
|
|
120
122
|
"execa": "latest",
|
|
121
123
|
"fs-extra": "10.x",
|
|
124
|
+
"glob": "^7.1.7",
|
|
122
125
|
"glob-gitignore": "latest",
|
|
123
126
|
"husky": "4.x",
|
|
124
127
|
"jest": "^27.0.0",
|
|
@@ -127,9 +130,9 @@
|
|
|
127
130
|
"lint-staged": "latest",
|
|
128
131
|
"node-fetch": "^2.6.1",
|
|
129
132
|
"npm-run-all": "latest",
|
|
130
|
-
"prettier": "2.3.
|
|
133
|
+
"prettier": "2.3.2",
|
|
131
134
|
"source-map": "latest",
|
|
132
|
-
"typescript": "
|
|
135
|
+
"typescript": "~4.2.4"
|
|
133
136
|
},
|
|
134
137
|
"lint-staged": {
|
|
135
138
|
"*.{ts,tsx,js,jsx}": [
|