ts-jest 25.5.0-beta.0 → 25.5.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/.ts-jest-digest +1 -1
- package/CHANGELOG.md +42 -0
- package/README.md +1 -0
- package/dist/cli/config/init.js +5 -5
- package/dist/cli/config/migrate.js +2 -2
- package/dist/compiler/compiler-utils.js +3 -4
- package/dist/compiler/instance.js +9 -11
- package/dist/compiler/language-service.js +6 -7
- package/dist/compiler/transpiler.js +1 -1
- package/dist/config/config-set.js +14 -21
- package/dist/index.d.ts +7 -0
- package/dist/ts-jest-transformer.js +2 -2
- package/dist/util/backports.js +1 -1
- package/dist/util/importer.js +1 -3
- package/package.json +10 -12
- package/preprocessor.js +1 -0
- package/presets/index.js +14 -7
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a17070bc22b8d4dcc13d502438e8b25aba2ac38d
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
|
+
<a name="25.5.0"></a>
|
|
2
|
+
# [25.5.0](https://github.com/kulshekhar/ts-jest/compare/v25.4.0...v25.5.0) (2020-05-05)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **compiler:** make `projectReferences` work with `isolatedModules: false` ([#1541](https://github.com/kulshekhar/ts-jest/issues/1541)) ([3e8efbe](https://github.com/kulshekhar/ts-jest/commit/3e8efbe))
|
|
8
|
+
* **compiler:** allow using `files` provided by `tsconfig` ([#1562](https://github.com/kulshekhar/ts-jest/issues/1562)) ([a9f02bd](https://github.com/kulshekhar/ts-jest/commit/a9f02bd))
|
|
9
|
+
* **config:** verify `testMatchPatterns` contain RegExp instance or string type values ([#1569](https://github.com/kulshekhar/ts-jest/issues/1569)) ([7f85bab](https://github.com/kulshekhar/ts-jest/commit/7f85bab))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **config:** add `tsconfig` alias to `tsConfig` option ([#1565](https://github.com/kulshekhar/ts-jest/issues/1565)) ([c10eb6d](https://github.com/kulshekhar/ts-jest/commit/c10eb6d))
|
|
15
|
+
* **config:** define 'ts-jest' on `ConfigGlobals` interface of `@jest/types` ([#1592](https://github.com/kulshekhar/ts-jest/issues/1592)) ([4526392](https://github.com/kulshekhar/ts-jest/commit/4526392))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Performance Improvements
|
|
19
|
+
|
|
20
|
+
* **compiler:** don’t write compile output to file system but rely on jest cache ([#1561](https://github.com/kulshekhar/ts-jest/issues/1561)) ([d11a4ea](https://github.com/kulshekhar/ts-jest/commit/d11a4ea))
|
|
21
|
+
* **compiler:** improve performance for `isolatedModules: false` ([#1558](https://github.com/kulshekhar/ts-jest/issues/1558)) ([85c09e3](https://github.com/kulshekhar/ts-jest/commit/85c09e3))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### BREAKING CHANGES
|
|
25
|
+
|
|
26
|
+
* Any custom typing files or files which are needed to be compiled and intended to use with `jest` need to be defined in `files` option of `tsconfig`.
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
```
|
|
30
|
+
// tsconfig.json
|
|
31
|
+
{
|
|
32
|
+
// ...other configs
|
|
33
|
+
"files": [
|
|
34
|
+
"my-custom-typings.d.ts".
|
|
35
|
+
"my-global-module.ts"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
* **compiler:** `incremental` and `compilerHost` options are no longer available. Please remove it from your `ts-jest` config.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
1
43
|
<a name="25.5.0-beta.0"></a>
|
|
2
44
|
# [25.5.0-beta.0](https://github.com/kulshekhar/ts-jest/compare/v25.5.0-alpha.0...v25.5.0-beta.0) (2020-04-29)
|
|
3
45
|
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://dependabot.com)
|
|
8
8
|
[](https://travis-ci.com/kulshekhar/ts-jest)
|
|
9
9
|
[](https://github.com/kulshekhar/ts-jest/actions)
|
|
10
|
+
[](https://github.com/kulshekhar/ts-jest/actions)
|
|
10
11
|
|
|
11
12
|
<img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
|
|
12
13
|
|
package/dist/cli/config/init.js
CHANGED
|
@@ -122,19 +122,19 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
|
|
|
122
122
|
content.push(" preset: '" + preset.name + "',");
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
content.push(
|
|
125
|
+
content.push(' ...tsjPreset,');
|
|
126
126
|
}
|
|
127
127
|
if (!jsdom)
|
|
128
128
|
content.push(" testEnvironment: 'node',");
|
|
129
129
|
if (tsconfig || shouldPostProcessWithBabel) {
|
|
130
|
-
content.push(
|
|
130
|
+
content.push(' globals: {');
|
|
131
131
|
content.push(" 'ts-jest': {");
|
|
132
132
|
if (tsconfig)
|
|
133
133
|
content.push(" tsconfig: " + json5_1.stringify(tsconfig) + ",");
|
|
134
134
|
if (shouldPostProcessWithBabel)
|
|
135
|
-
content.push(
|
|
136
|
-
content.push(
|
|
137
|
-
content.push(
|
|
135
|
+
content.push(' babelConfig: true,');
|
|
136
|
+
content.push(' },');
|
|
137
|
+
content.push(' },');
|
|
138
138
|
}
|
|
139
139
|
content.push('};');
|
|
140
140
|
body = content.join('\n');
|
|
@@ -166,8 +166,8 @@ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, functio
|
|
|
166
166
|
process.stderr.write("\nNo migration needed for given Jest configuration\n ");
|
|
167
167
|
return [2];
|
|
168
168
|
}
|
|
169
|
-
stringify =
|
|
170
|
-
prefix =
|
|
169
|
+
stringify = file.endsWith('.json') ? JSON.stringify : json5_1.stringify;
|
|
170
|
+
prefix = file.endsWith('.json') ? '"jest": ' : 'module.exports = ';
|
|
171
171
|
if (preset && migratedConfig.transform) {
|
|
172
172
|
footNotes.push("\nI couldn't check if your \"transform\" value is the same as mine which is: " + stringify(preset.value.transform, undefined, ' ') + "\nIf it is the case, you can safely remove the \"transform\" from what I've migrated.\n");
|
|
173
173
|
}
|
|
@@ -22,7 +22,6 @@ var path_1 = require("path");
|
|
|
22
22
|
var _ts = require("typescript");
|
|
23
23
|
var constants_1 = require("../constants");
|
|
24
24
|
var sha1_1 = require("../util/sha1");
|
|
25
|
-
exports.hasOwn = Object.prototype.hasOwnProperty;
|
|
26
25
|
function getResolvedModulesCache(cacheDir) {
|
|
27
26
|
return path_1.join(cacheDir, sha1_1.sha1('ts-jest-resolved-modules', '\x00'));
|
|
28
27
|
}
|
|
@@ -30,7 +29,7 @@ exports.getResolvedModulesCache = getResolvedModulesCache;
|
|
|
30
29
|
function cacheResolvedModules(fileName, fileContent, memoryCache, program, cacheDir, logger) {
|
|
31
30
|
var importReferences = program.getSourceFile(fileName).imports;
|
|
32
31
|
if (importReferences.length) {
|
|
33
|
-
logger.debug({ fileName: fileName },
|
|
32
|
+
logger.debug({ fileName: fileName }, 'cacheResolvedModules(): get resolved modules');
|
|
34
33
|
memoryCache.resolvedModules[fileName] = Object.create(null);
|
|
35
34
|
memoryCache.resolvedModules[fileName].modulePaths = importReferences
|
|
36
35
|
.filter(function (importReference) { var _a; return (_a = importReference.parent.parent.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(importReference.text); })
|
|
@@ -122,9 +121,9 @@ function getCompileResultFromReferencedProject(fileName, configs, files, referen
|
|
|
122
121
|
var jsFileName = getAndCacheOutputJSFileName(fileName, referencedProject, files);
|
|
123
122
|
var relativeJSFileName = configs.resolvePath(jsFileName);
|
|
124
123
|
if (!configs.compilerModule.sys.fileExists(jsFileName)) {
|
|
125
|
-
throw new Error(
|
|
124
|
+
throw new Error('Could not find output JavaScript file for input ' +
|
|
126
125
|
(relativeFilePath + " (looked at " + relativeJSFileName + ").\n") +
|
|
127
|
-
|
|
126
|
+
'The input file is part of a project reference located at ' +
|
|
128
127
|
(relativeProjectConfigPath + ", so ts-jest is looking for the ") +
|
|
129
128
|
'project’s pre-built output on disk. Try running `tsc --build` ' +
|
|
130
129
|
'to build project references.');
|
|
@@ -47,18 +47,16 @@ var updateSourceMap = function (sourceMapText, normalizedFileName) {
|
|
|
47
47
|
delete sourceMap.sourceRoot;
|
|
48
48
|
return JSON.stringify(sourceMap);
|
|
49
49
|
};
|
|
50
|
-
var compileAndCacheResult = function (memoryCache, compileFn, getExtension, logger) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
58
|
-
};
|
|
50
|
+
var compileAndCacheResult = function (memoryCache, compileFn, getExtension, logger) { return function (code, fileName, lineOffset) {
|
|
51
|
+
logger.debug({ fileName: fileName }, 'compileAndCacheResult(): get compile output');
|
|
52
|
+
var _a = __read(compileFn(code, fileName, lineOffset), 2), value = _a[0], sourceMap = _a[1];
|
|
53
|
+
var output = updateOutput(value, fileName, sourceMap, getExtension);
|
|
54
|
+
memoryCache.files.set(fileName, __assign(__assign({}, memoryCache.files.get(fileName)), { output: output }));
|
|
55
|
+
return output;
|
|
56
|
+
}; };
|
|
59
57
|
exports.createCompilerInstance = function (configs) {
|
|
60
58
|
var logger = configs.logger.child({ namespace: 'ts-compiler' });
|
|
61
|
-
var compilerOptions = configs.
|
|
59
|
+
var compilerOptions = configs.parsedTsConfig.options, tsJest = configs.tsJest;
|
|
62
60
|
var cacheDir = configs.tsCacheDir;
|
|
63
61
|
var ts = configs.compilerModule;
|
|
64
62
|
var extensions = ['.ts', '.tsx'];
|
|
@@ -78,7 +76,7 @@ exports.createCompilerInstance = function (configs) {
|
|
|
78
76
|
}
|
|
79
77
|
catch (e) { }
|
|
80
78
|
}
|
|
81
|
-
configs.
|
|
79
|
+
configs.parsedTsConfig.fileNames.forEach(function (fileName) {
|
|
82
80
|
memoryCache.files.set(fileName, {
|
|
83
81
|
version: 0,
|
|
84
82
|
});
|
|
@@ -38,7 +38,7 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
|
|
|
38
38
|
var ts = configs.compilerModule;
|
|
39
39
|
var cwd = configs.cwd;
|
|
40
40
|
var cacheDir = configs.tsCacheDir;
|
|
41
|
-
var _b = configs.
|
|
41
|
+
var _b = configs.parsedTsConfig, options = _b.options, projectReferences = _b.projectReferences, fileNames = _b.fileNames;
|
|
42
42
|
var serviceHostTraceCtx = (_a = {
|
|
43
43
|
namespace: 'ts:serviceHost',
|
|
44
44
|
call: null
|
|
@@ -50,7 +50,7 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
|
|
|
50
50
|
}
|
|
51
51
|
var projectVersion = 1;
|
|
52
52
|
var updateMemoryCache = function (contents, fileName) {
|
|
53
|
-
logger.debug({ fileName: fileName },
|
|
53
|
+
logger.debug({ fileName: fileName }, 'updateMemoryCache(): update memory cache for language service');
|
|
54
54
|
var shouldIncrementProjectVersion = false;
|
|
55
55
|
var hit = isFileInCache(fileName);
|
|
56
56
|
if (!hit) {
|
|
@@ -90,7 +90,7 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
|
|
|
90
90
|
var _a;
|
|
91
91
|
var normalizedFileName = path_1.normalize(fileName);
|
|
92
92
|
var hit = memoryCache.files.has(normalizedFileName) && memoryCache.files.get(normalizedFileName).version !== 0;
|
|
93
|
-
logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit },
|
|
93
|
+
logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
|
94
94
|
if (!hit) {
|
|
95
95
|
memoryCache.files.set(normalizedFileName, {
|
|
96
96
|
text: ts.sys.readFile(normalizedFileName),
|
|
@@ -127,7 +127,7 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
|
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
129
|
var output = service.getEmitOutput(fileName);
|
|
130
|
-
logger.debug({ fileName: fileName },
|
|
130
|
+
logger.debug({ fileName: fileName }, 'compileFn(): computing diagnostics using language service');
|
|
131
131
|
doTypeChecking(configs, fileName, service, logger);
|
|
132
132
|
if (cacheDir) {
|
|
133
133
|
if (compiler_utils_1.isTestFile(configs.testMatchPatterns, fileName)) {
|
|
@@ -136,13 +136,12 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
|
|
|
136
136
|
else {
|
|
137
137
|
Object.entries(memoryCache.resolvedModules)
|
|
138
138
|
.filter(function (entry) {
|
|
139
|
-
return
|
|
140
|
-
!compiler_utils_1.hasOwn.call(memoryCache.files, entry[0]));
|
|
139
|
+
return entry[1].modulePaths.find(function (modulePath) { return modulePath === fileName; }) && !memoryCache.files.has(entry[0]);
|
|
141
140
|
})
|
|
142
141
|
.forEach(function (entry) {
|
|
143
142
|
var testFileName = entry[0];
|
|
144
143
|
var testFileContent = entry[1].testFileContent;
|
|
145
|
-
logger.debug({ fileName: fileName },
|
|
144
|
+
logger.debug({ fileName: fileName }, 'compileFn(): computing diagnostics for test file that imports this module using language service');
|
|
146
145
|
updateMemoryCache(testFileContent, testFileName);
|
|
147
146
|
doTypeChecking(configs, testFileName, service, logger);
|
|
148
147
|
});
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var compiler_utils_1 = require("./compiler-utils");
|
|
4
4
|
exports.initializeTranspilerInstance = function (configs, memoryCache, logger) {
|
|
5
5
|
logger.debug('initializeTranspilerInstance(): create typescript compiler');
|
|
6
|
-
var _a = configs.
|
|
6
|
+
var _a = configs.parsedTsConfig, options = _a.options, projectReferences = _a.projectReferences, fileNames = _a.fileNames;
|
|
7
7
|
var ts = configs.compilerModule;
|
|
8
8
|
var program = projectReferences
|
|
9
9
|
? ts.createProgram({
|
|
@@ -289,9 +289,9 @@ var ConfigSet = (function () {
|
|
|
289
289
|
enumerable: true,
|
|
290
290
|
configurable: true
|
|
291
291
|
});
|
|
292
|
-
Object.defineProperty(ConfigSet.prototype, "
|
|
292
|
+
Object.defineProperty(ConfigSet.prototype, "parsedTsConfig", {
|
|
293
293
|
get: function () {
|
|
294
|
-
return this.
|
|
294
|
+
return this._parsedTsConfig;
|
|
295
295
|
},
|
|
296
296
|
enumerable: true,
|
|
297
297
|
configurable: true
|
|
@@ -311,12 +311,12 @@ var ConfigSet = (function () {
|
|
|
311
311
|
enumerable: true,
|
|
312
312
|
configurable: true
|
|
313
313
|
});
|
|
314
|
-
Object.defineProperty(ConfigSet.prototype, "
|
|
314
|
+
Object.defineProperty(ConfigSet.prototype, "_parsedTsConfig", {
|
|
315
315
|
get: function () {
|
|
316
316
|
var tsConfig = this.tsJest.tsConfig;
|
|
317
317
|
var configFilePath = tsConfig && tsConfig.kind === 'file' ? tsConfig.value : undefined;
|
|
318
318
|
var result = this.readTsConfig(tsConfig && tsConfig.kind === 'inline' ? tsConfig.value : undefined, configFilePath, tsConfig == null);
|
|
319
|
-
this.raiseDiagnostics(result.
|
|
319
|
+
this.raiseDiagnostics(result.errors, configFilePath);
|
|
320
320
|
this.logger.debug({ tsconfig: result }, 'normalized typescript config');
|
|
321
321
|
return result;
|
|
322
322
|
},
|
|
@@ -348,7 +348,7 @@ var ConfigSet = (function () {
|
|
|
348
348
|
var babelConfig = this.tsJest.babelConfig;
|
|
349
349
|
if (babelConfig == null) {
|
|
350
350
|
this.logger.debug('babel is disabled');
|
|
351
|
-
return;
|
|
351
|
+
return undefined;
|
|
352
352
|
}
|
|
353
353
|
var base = { cwd: this.cwd };
|
|
354
354
|
if (babelConfig.kind === 'file') {
|
|
@@ -381,7 +381,7 @@ var ConfigSet = (function () {
|
|
|
381
381
|
get: function () {
|
|
382
382
|
var babel = this.babel;
|
|
383
383
|
if (!babel)
|
|
384
|
-
return;
|
|
384
|
+
return undefined;
|
|
385
385
|
this.logger.debug('creating babel-jest transformer');
|
|
386
386
|
return importer_1.importer.babelJest("Using \"babel-jest\" requires this package to be installed.").createTransformer(babel);
|
|
387
387
|
},
|
|
@@ -435,7 +435,7 @@ var ConfigSet = (function () {
|
|
|
435
435
|
if (((_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.fileName) && !shouldReportDiagnostic(diagnostic.file.fileName)) {
|
|
436
436
|
return false;
|
|
437
437
|
}
|
|
438
|
-
return ignoreCodes.
|
|
438
|
+
return !ignoreCodes.includes(diagnostic.code);
|
|
439
439
|
});
|
|
440
440
|
};
|
|
441
441
|
},
|
|
@@ -495,14 +495,14 @@ var ConfigSet = (function () {
|
|
|
495
495
|
get: function () {
|
|
496
496
|
if (!this.jest.cache) {
|
|
497
497
|
logger.debug('file caching disabled');
|
|
498
|
-
return;
|
|
498
|
+
return undefined;
|
|
499
499
|
}
|
|
500
500
|
var cacheSuffix = sha1_1.sha1(json_1.stringify({
|
|
501
501
|
version: this.compilerModule.version,
|
|
502
502
|
digest: this.tsJestDigest,
|
|
503
503
|
dependencies: this.projectDependencies,
|
|
504
504
|
compiler: this.tsJest.compiler,
|
|
505
|
-
compilerOptions: this.
|
|
505
|
+
compilerOptions: this.parsedTsConfig.options,
|
|
506
506
|
isolatedModules: this.tsJest.isolatedModules,
|
|
507
507
|
diagnostics: this.tsJest.diagnostics,
|
|
508
508
|
}));
|
|
@@ -575,7 +575,7 @@ var ConfigSet = (function () {
|
|
|
575
575
|
jest: jest,
|
|
576
576
|
tsJest: this.tsJest,
|
|
577
577
|
babel: this.babel,
|
|
578
|
-
tsconfig: this.
|
|
578
|
+
tsconfig: this.parsedTsConfig.options,
|
|
579
579
|
});
|
|
580
580
|
},
|
|
581
581
|
enumerable: true,
|
|
@@ -606,11 +606,7 @@ var ConfigSet = (function () {
|
|
|
606
606
|
var basePath = normalize_slashes_1.normalizeSlashes(this.rootDir);
|
|
607
607
|
var configFileName;
|
|
608
608
|
var ts = this.compilerModule;
|
|
609
|
-
|
|
610
|
-
if (noProject) {
|
|
611
|
-
input = { compilerOptions: __assign({}, compilerOptions) };
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
609
|
+
if (!noProject) {
|
|
614
610
|
configFileName = resolvedConfigFile
|
|
615
611
|
? normalize_slashes_1.normalizeSlashes(resolvedConfigFile)
|
|
616
612
|
: ts.findConfigFile(normalize_slashes_1.normalizeSlashes(this.rootDir), ts.sys.fileExists);
|
|
@@ -618,12 +614,9 @@ var ConfigSet = (function () {
|
|
|
618
614
|
this.logger.debug({ tsConfigFileName: configFileName }, 'readTsConfig(): reading', configFileName);
|
|
619
615
|
var result_1 = ts.readConfigFile(configFileName, ts.sys.readFile);
|
|
620
616
|
if (result_1.error) {
|
|
621
|
-
return {
|
|
622
|
-
resolved: { errors: [result_1.error], fileNames: [], options: {} },
|
|
623
|
-
};
|
|
617
|
+
return { errors: [result_1.error], fileNames: [], options: {} };
|
|
624
618
|
}
|
|
625
619
|
config = result_1.config;
|
|
626
|
-
input = __assign(__assign({}, result_1.config), { compilerOptions: __assign(__assign({}, (result_1.config && result_1.config.compilerOptions)), compilerOptions) });
|
|
627
620
|
basePath = normalize_slashes_1.normalizeSlashes(path_1.dirname(configFileName));
|
|
628
621
|
}
|
|
629
622
|
}
|
|
@@ -672,7 +665,7 @@ var ConfigSet = (function () {
|
|
|
672
665
|
}
|
|
673
666
|
finally { if (e_2) throw e_2.error; }
|
|
674
667
|
}
|
|
675
|
-
return
|
|
668
|
+
return result;
|
|
676
669
|
};
|
|
677
670
|
ConfigSet.prototype.resolvePath = function (inputPath, _a) {
|
|
678
671
|
var _b = _a === void 0 ? {} : _a, _c = _b.throwIfMissing, throwIfMissing = _c === void 0 ? true : _c, _d = _b.nodeResolve, nodeResolve = _d === void 0 ? false : _d;
|
|
@@ -729,7 +722,7 @@ var ConfigSet = (function () {
|
|
|
729
722
|
], ConfigSet.prototype, "versions", null);
|
|
730
723
|
__decorate([
|
|
731
724
|
memoize_1.Memoize()
|
|
732
|
-
], ConfigSet.prototype, "
|
|
725
|
+
], ConfigSet.prototype, "_parsedTsConfig", null);
|
|
733
726
|
__decorate([
|
|
734
727
|
memoize_1.Memoize()
|
|
735
728
|
], ConfigSet.prototype, "raiseDiagnostics", null);
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { createJestPreset as createJestPresetCore } from './config/create-jest-p
|
|
|
2
2
|
import { TsJestTransformer } from './ts-jest-transformer';
|
|
3
3
|
import { TsJestGlobalOptions } from './types';
|
|
4
4
|
import { mocked as mockedCore } from './util/testing';
|
|
5
|
+
declare module '@jest/types' {
|
|
6
|
+
namespace Config {
|
|
7
|
+
interface ConfigGlobals {
|
|
8
|
+
'ts-jest': TsJestGlobalOptions;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
5
12
|
export declare const mocked: typeof mockedCore;
|
|
6
13
|
export declare const createJestPreset: typeof createJestPresetCore;
|
|
7
14
|
export declare const pathsToModuleNameMapper: (mapping: import("typescript").MapLike<string[]>, { prefix }?: {
|
|
@@ -52,7 +52,7 @@ var TsJestTransformer = (function () {
|
|
|
52
52
|
return csi.configSet;
|
|
53
53
|
}
|
|
54
54
|
var jestConfigObj = jestConfig;
|
|
55
|
-
this.logger.info(
|
|
55
|
+
this.logger.info('no matching config-set found, creating a new one');
|
|
56
56
|
var configSet = new config_set_1.ConfigSet(jestConfigObj, this.options, this.logger);
|
|
57
57
|
TsJestTransformer._configSetsIndex.push({
|
|
58
58
|
jestConfig: new jsonable_value_1.JsonableValue(jestConfigObj),
|
|
@@ -77,7 +77,7 @@ var TsJestTransformer = (function () {
|
|
|
77
77
|
else if (isDefinitionFile) {
|
|
78
78
|
result = '';
|
|
79
79
|
}
|
|
80
|
-
else if (!configs.
|
|
80
|
+
else if (!configs.parsedTsConfig.options.allowJs && isJsFile) {
|
|
81
81
|
this.logger.warn({ fileName: filePath }, messages_1.interpolate("Got a `.js` file to compile while `allowJs` option is not set to `true` (file: {{path}}). To fix this:\n - if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)\n - if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore", { path: filePath }));
|
|
82
82
|
result = source;
|
|
83
83
|
}
|
package/dist/util/backports.js
CHANGED
|
@@ -91,7 +91,7 @@ exports.backportTsJestDebugEnvVar = function (logger) {
|
|
|
91
91
|
var shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '');
|
|
92
92
|
delete process.env.TS_JEST_DEBUG;
|
|
93
93
|
if (shouldLog) {
|
|
94
|
-
process.env.TS_JEST_LOG =
|
|
94
|
+
process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn';
|
|
95
95
|
}
|
|
96
96
|
logger.warn(context, messages_1.interpolate("Using env. var \"{{old}}\" is deprecated, use \"{{new}}\" instead.", {
|
|
97
97
|
old: 'TS_JEST_DEBUG',
|
package/dist/util/importer.js
CHANGED
|
@@ -136,9 +136,7 @@ var Importer = (function () {
|
|
|
136
136
|
installTip = [{ module: installTip, label: "install \"" + installTip + "\"" }];
|
|
137
137
|
}
|
|
138
138
|
var fix = installTip
|
|
139
|
-
.map(function (tip) {
|
|
140
|
-
return " " + (installTip.length === 1 ? '↳' : '•') + " " + messages_1.interpolate("{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)", tip);
|
|
141
|
-
})
|
|
139
|
+
.map(function (tip) { return " " + (installTip.length === 1 ? '↳' : '•') + " " + messages_1.interpolate("{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)", tip); })
|
|
142
140
|
.join('\n');
|
|
143
141
|
throw new Error(messages_1.interpolate(msg, {
|
|
144
142
|
module: loadModule,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "25.5.0
|
|
3
|
+
"version": "25.5.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": "cli.js",
|
|
@@ -19,12 +19,8 @@
|
|
|
19
19
|
"test:unit": "node_modules/.bin/jest",
|
|
20
20
|
"test:external": "node scripts/test-external-project.js",
|
|
21
21
|
"test:external-repos": "npm run test:external external-repos",
|
|
22
|
-
"lint": "
|
|
23
|
-
"lint:
|
|
24
|
-
"lint:ts": "node_modules/.bin/tslint -t stylish --project .",
|
|
25
|
-
"lint:fix": "run-s lint:fix:ts lint:fix:js",
|
|
26
|
-
"lint:fix:js": "node_modules/.bin/eslint . --fix",
|
|
27
|
-
"lint:fix:ts": "node_modules/.bin/tslint --fix --project .",
|
|
22
|
+
"lint": "node_modules/.bin/eslint --ext .js,.ts .",
|
|
23
|
+
"lint:fix": "node_modules/.bin/eslint --fix --ext .js,.ts .",
|
|
28
24
|
"typecheck": "node_modules/.bin/tsc -p .",
|
|
29
25
|
"doc": "cd docs && bundle exec jekyll serve --livereload",
|
|
30
26
|
"doc:link": "git worktree add docs/_site gh-pages",
|
|
@@ -102,13 +98,18 @@
|
|
|
102
98
|
"@types/mkdirp": "latest",
|
|
103
99
|
"@types/node": "10.x",
|
|
104
100
|
"@types/react": "16.x",
|
|
105
|
-
"@types/resolve": "latest",
|
|
106
101
|
"@types/semver": "latest",
|
|
107
102
|
"@types/yargs": "latest",
|
|
108
103
|
"@types/yargs-parser": "15.x",
|
|
104
|
+
"@typescript-eslint/eslint-plugin": "latest",
|
|
105
|
+
"@typescript-eslint/parser": "latest",
|
|
109
106
|
"conventional-changelog-cli": "2.x",
|
|
110
107
|
"cross-spawn": "latest",
|
|
111
108
|
"eslint": "latest",
|
|
109
|
+
"eslint-config-prettier": "latest",
|
|
110
|
+
"eslint-plugin-jest": "latest",
|
|
111
|
+
"eslint-plugin-jsdoc": "latest",
|
|
112
|
+
"eslint-plugin-prettier": "latest",
|
|
112
113
|
"fs-extra": "8.x",
|
|
113
114
|
"glob-gitignore": "latest",
|
|
114
115
|
"husky": "3.x",
|
|
@@ -120,14 +121,11 @@
|
|
|
120
121
|
"npm-run-all": "latest",
|
|
121
122
|
"prettier": "1.x",
|
|
122
123
|
"source-map": "latest",
|
|
123
|
-
"tslint": "latest",
|
|
124
|
-
"tslint-config-prettier": "latest",
|
|
125
|
-
"tslint-plugin-prettier": "latest",
|
|
126
124
|
"typescript": "3.x"
|
|
127
125
|
},
|
|
128
126
|
"lint-staged": {
|
|
129
127
|
"*.{ts,tsx}": [
|
|
130
|
-
"
|
|
128
|
+
"eslint --fix",
|
|
131
129
|
"git add"
|
|
132
130
|
],
|
|
133
131
|
"*.{js,jsx}": [
|
package/preprocessor.js
CHANGED
package/presets/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
const create = require('./create')
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
get defaults() {
|
|
5
|
-
|
|
4
|
+
get defaults() {
|
|
5
|
+
return create()
|
|
6
|
+
},
|
|
7
|
+
get jsWithTs() {
|
|
8
|
+
return create({ allowJs: true })
|
|
9
|
+
},
|
|
6
10
|
get jsWithBabel() {
|
|
7
|
-
return create(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
return create(
|
|
12
|
+
{ allowJs: false },
|
|
13
|
+
{
|
|
14
|
+
transform: {
|
|
15
|
+
'^.+\\.jsx?$': 'babel-jest',
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
)
|
|
12
19
|
},
|
|
13
20
|
}
|