ts-jest 25.5.0-alpha.0 → 25.5.1

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 CHANGED
@@ -1 +1 @@
1
- 464afed43df8c2fbe76caa3aa2944507acb644cf
1
+ d9672057404fee19f80db714ea000c61a1375776
package/CHANGELOG.md CHANGED
@@ -1,20 +1,109 @@
1
- <a name="25.5.0-alpha.0"></a>
2
- # [25.5.0-alpha.0](https://github.com/kulshekhar/ts-jest/compare/v25.4.0...v25.5.0-alpha.0) (2020-04-22)
1
+ <a name="25.5.1"></a>
2
+ ## [25.5.1](https://github.com/kulshekhar/ts-jest/compare/v25.5.0...v25.5.1) (2020-05-09)
3
3
 
4
4
 
5
5
  ### Bug Fixes
6
6
 
7
- * **compiler:** make `projectReferences` work with `LanguageService` ([#1541](https://github.com/kulshekhar/ts-jest/issues/1541)) ([3e8efbe](https://github.com/kulshekhar/ts-jest/commit/3e8efbe))
7
+ * **compiler:** don't resolve files from build folder for `projectReferences` ([#1614](https://github.com/kulshekhar/ts-jest/issues/1614)) ([74b92d3](https://github.com/kulshekhar/ts-jest/commit/74b92d3))
8
+ * **config:** don't set `include` value of `tsconfig` to empty array ([#1606](https://github.com/kulshekhar/ts-jest/issues/1606)) ([8a29aaa](https://github.com/kulshekhar/ts-jest/commit/8a29aaa))
8
9
 
9
10
 
10
- ### Chores
11
11
 
12
- * **compiler:** use `Incremental Program` for `compilerHost` option ([#1535](https://github.com/kulshekhar/ts-jest/issues/1535)) ([a7250b6](https://github.com/kulshekhar/ts-jest/commit/a7250b6))
12
+ <a name="25.5.0"></a>
13
+ # [25.5.0](https://github.com/kulshekhar/ts-jest/compare/v25.4.0...v25.5.0) (2020-05-05)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **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))
19
+ * **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))
20
+ * **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))
21
+
22
+
23
+ ### Features
24
+
25
+ * **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))
26
+ * **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))
27
+
28
+
29
+ ### Performance Improvements
30
+
31
+ * **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))
32
+ * **compiler:** improve performance for `isolatedModules: false` ([#1558](https://github.com/kulshekhar/ts-jest/issues/1558)) ([85c09e3](https://github.com/kulshekhar/ts-jest/commit/85c09e3))
33
+
34
+
35
+ ### BREAKING CHANGES
36
+
37
+ * 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`.
38
+
39
+ For example:
40
+ ```
41
+ // tsconfig.json
42
+ {
43
+ // ...other configs
44
+ "files": [
45
+ "my-custom-typings.d.ts",
46
+ "my-global-module.ts"
47
+ ]
48
+ }
49
+ ```
50
+ * **compiler:** `incremental` and `compilerHost` options are no longer available. Please remove it from your `ts-jest` config.
51
+
52
+
53
+
54
+ <a name="25.5.0-beta.0"></a>
55
+ # [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)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * **compiler:** allow using `files` provided by `tsconfig` ([#1562](https://github.com/kulshekhar/ts-jest/issues/1562)) ([907a280](https://github.com/kulshekhar/ts-jest/commit/907a280))
61
+ * **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))
62
+
63
+
64
+ ### Features
65
+
66
+ * **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))
67
+
68
+
69
+ ### Performance Improvements
70
+
71
+ * **compiler:** don’t write compile output to file system but rely on `jest` cache ([#1561](https://github.com/kulshekhar/ts-jest/issues/1561)) ([07b5f62](https://github.com/kulshekhar/ts-jest/commit/07b5f62))
72
+
73
+
74
+ ### BREAKING CHANGES
75
+
76
+ * 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`.
77
+
78
+ For example
79
+ ```
80
+ // tsconfig.json
81
+ {
82
+ // ...other configs
83
+ "files": [
84
+ "my-custom-typings.d.ts".
85
+ "my-global-module.ts"
86
+ ]
87
+ }
88
+ ```
89
+
90
+
91
+
92
+ <a name="25.5.0-alpha.0"></a>
93
+ # [25.5.0-alpha.0](https://github.com/kulshekhar/ts-jest/compare/v25.4.0...v25.5.0-alpha.0) (2020-04-22)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * **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))
99
+
100
+ ### Performance
13
101
 
102
+ * **compiler:** improve performance for `isolatedModules: false` ([#1558](https://github.com/kulshekhar/ts-jest/issues/1558)) ([85c09e3](https://github.com/kulshekhar/ts-jest/commit/85c09e3))
14
103
 
15
104
  ### BREAKING CHANGES
16
105
 
17
- * **compiler:** `incremental` option is no longer available. By default, `compilerHost` always uses TypeScript `Incremental Program`
106
+ * **config:** `compilerHost` and `incremental` options are no longer available
18
107
 
19
108
 
20
109
 
package/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=kulshekhar/ts-jest)](https://dependabot.com)
8
8
  [![Build Status](https://travis-ci.com/kulshekhar/ts-jest.svg?branch=master)](https://travis-ci.com/kulshekhar/ts-jest)
9
9
  [![doc-generator](https://github.com/kulshekhar/ts-jest/workflows/doc-generator/badge.svg)](https://github.com/kulshekhar/ts-jest/actions)
10
+ [![release-and-publish](https://github.com/kulshekhar/ts-jest/workflows/release-and-publish/badge.svg)](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
 
@@ -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(" ...tsjPreset,");
125
+ content.push(' ...tsjPreset,');
126
126
  }
127
127
  if (!jsdom)
128
128
  content.push(" testEnvironment: 'node',");
129
129
  if (tsconfig || shouldPostProcessWithBabel) {
130
- content.push(" globals: {");
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(" babelConfig: true,");
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 = /\.json$/.test(file) ? JSON.stringify : json5_1.stringify;
170
- prefix = /\.json$/.test(file) ? '"jest": ' : 'module.exports = ';
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
  }
@@ -1,26 +1,8 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  var fs_1 = require("fs");
20
4
  var micromatch = require("micromatch");
21
5
  var path_1 = require("path");
22
- var _ts = require("typescript");
23
- var constants_1 = require("../constants");
24
6
  var sha1_1 = require("../util/sha1");
25
7
  function getResolvedModulesCache(cacheDir) {
26
8
  return path_1.join(cacheDir, sha1_1.sha1('ts-jest-resolved-modules', '\x00'));
@@ -29,7 +11,7 @@ exports.getResolvedModulesCache = getResolvedModulesCache;
29
11
  function cacheResolvedModules(fileName, fileContent, memoryCache, program, cacheDir, logger) {
30
12
  var importReferences = program.getSourceFile(fileName).imports;
31
13
  if (importReferences.length) {
32
- logger.debug({ fileName: fileName }, "cacheResolvedModules(): get resolved modules of test file " + fileName);
14
+ logger.debug({ fileName: fileName }, 'cacheResolvedModules(): get resolved modules');
33
15
  memoryCache.resolvedModules[fileName] = Object.create(null);
34
16
  memoryCache.resolvedModules[fileName].modulePaths = importReferences
35
17
  .filter(function (importReference) { var _a; return (_a = importReference.parent.parent.resolvedModules) === null || _a === void 0 ? void 0 : _a.get(importReference.text); })
@@ -49,86 +31,3 @@ function isTestFile(testMatchPatterns, fileName) {
49
31
  });
50
32
  }
51
33
  exports.isTestFile = isTestFile;
52
- function isUsingProjectReferences(program, projectReferences) {
53
- if (projectReferences && !!program.getProjectReferences) {
54
- return Boolean(program && program.getProjectReferences());
55
- }
56
- return false;
57
- }
58
- function getResolvedProjectReferences(program) {
59
- var getProjectReferences = program.getResolvedProjectReferences || program.getProjectReferences;
60
- if (getProjectReferences) {
61
- return getProjectReferences();
62
- }
63
- return;
64
- }
65
- function getProjectReferenceForFile(filePath, program, projectReferences) {
66
- if (isUsingProjectReferences(program, projectReferences)) {
67
- return (program &&
68
- getResolvedProjectReferences(program).find(function (ref) { return (ref && ref.commandLine.fileNames.some(function (file) { return path_1.normalize(file) === filePath; })) || false; }));
69
- }
70
- return;
71
- }
72
- function getAndCacheProjectReference(filePath, program, files, projectReferences) {
73
- var file = files.get(filePath);
74
- if (file !== undefined && file.projectReference) {
75
- return file.projectReference.project;
76
- }
77
- var projectReference = getProjectReferenceForFile(filePath, program, projectReferences);
78
- if (file !== undefined) {
79
- file.projectReference = { project: projectReference };
80
- }
81
- return projectReference;
82
- }
83
- exports.getAndCacheProjectReference = getAndCacheProjectReference;
84
- function getOutputJavaScriptFileName(inputFileName, projectReference) {
85
- var options = projectReference.commandLine.options;
86
- var projectDirectory = options.rootDir || path_1.dirname(projectReference.sourceFile.fileName);
87
- var relativePath = path_1.relative(projectDirectory, inputFileName);
88
- var outputPath = path_1.resolve(options.outDir || projectDirectory, relativePath);
89
- var newExtension = constants_1.JSON_REGEX.test(inputFileName)
90
- ? '.json'
91
- : constants_1.TS_TSX_REGEX.test(inputFileName) && options.jsx === _ts.JsxEmit.Preserve
92
- ? '.jsx'
93
- : '.js';
94
- return outputPath.replace(constants_1.EXTENSION_REGEX, newExtension);
95
- }
96
- function getAndCacheOutputJSFileName(inputFileName, projectReference, files) {
97
- var file = files.get(inputFileName);
98
- if (file && file.projectReference && file.projectReference.outputFileName) {
99
- return file.projectReference.outputFileName;
100
- }
101
- var outputFileName = getOutputJavaScriptFileName(inputFileName, projectReference);
102
- if (file !== undefined) {
103
- file.projectReference = file.projectReference || {
104
- project: projectReference,
105
- };
106
- file.projectReference.outputFileName = outputFileName;
107
- }
108
- return outputFileName;
109
- }
110
- function getCompileResultFromReferencedProject(fileName, configs, files, referencedProject) {
111
- var _a = __read([
112
- configs.resolvePath(referencedProject.sourceFile.fileName),
113
- configs.resolvePath(fileName),
114
- ], 2), relativeProjectConfigPath = _a[0], relativeFilePath = _a[1];
115
- if (referencedProject.commandLine.options.outFile !== undefined) {
116
- throw new Error("The referenced project at " + relativeProjectConfigPath + " is using " +
117
- "the outFile' option, which is not supported with ts-jest.");
118
- }
119
- var jsFileName = getAndCacheOutputJSFileName(fileName, referencedProject, files);
120
- var relativeJSFileName = configs.resolvePath(jsFileName);
121
- if (!configs.compilerModule.sys.fileExists(jsFileName)) {
122
- throw new Error("Could not find output JavaScript file for input " +
123
- (relativeFilePath + " (looked at " + relativeJSFileName + ").\n") +
124
- "The input file is part of a project reference located at " +
125
- (relativeProjectConfigPath + ", so ts-jest is looking for the ") +
126
- 'project’s pre-built output on disk. Try running `tsc --build` ' +
127
- 'to build project references.');
128
- }
129
- var mapFileName = jsFileName + ".map";
130
- var outputText = configs.compilerModule.sys.readFile(jsFileName);
131
- var sourceMapText = configs.compilerModule.sys.readFile(mapFileName);
132
- return [outputText, sourceMapText];
133
- }
134
- exports.getCompileResultFromReferencedProject = getCompileResultFromReferencedProject;
@@ -30,7 +30,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
30
30
  var fs_1 = require("fs");
31
31
  var mkdirp = require("mkdirp");
32
32
  var path_1 = require("path");
33
- var sha1_1 = require("../util/sha1");
34
33
  var compiler_utils_1 = require("./compiler-utils");
35
34
  var language_service_1 = require("./language-service");
36
35
  var transpiler_1 = require("./transpiler");
@@ -48,54 +47,22 @@ var updateSourceMap = function (sourceMapText, normalizedFileName) {
48
47
  delete sourceMap.sourceRoot;
49
48
  return JSON.stringify(sourceMap);
50
49
  };
51
- var getCacheName = function (sourceCode, normalizedFileName) {
52
- return sha1_1.sha1(normalizedFileName, '\x00', sourceCode);
53
- };
54
- var isValidCacheContent = function (contents) {
55
- return /(?:9|0=|Q==)$/.test(contents.slice(-3));
56
- };
57
- var compileAndCacheResult = function (cacheDir, memoryCache, compileFn, getExtension, logger) {
58
- return function (code, fileName, lineOffset) {
59
- function getCompileOutput() {
60
- var _a = __read(compileFn(code, fileName, lineOffset), 2), value = _a[0], sourceMap = _a[1];
61
- var output = updateOutput(value, fileName, sourceMap, getExtension);
62
- memoryCache.files.set(fileName, __assign(__assign({}, memoryCache.files.get(fileName)), { output: output }));
63
- return output;
64
- }
65
- if (!cacheDir) {
66
- logger.debug({ fileName: fileName }, 'compileAndCacheResult(): no cache');
67
- return getCompileOutput();
68
- }
69
- else {
70
- var cachePath = path_1.join(cacheDir, getCacheName(code, fileName));
71
- var extension = getExtension(fileName);
72
- var outputPath = "" + cachePath + extension;
73
- try {
74
- var output_1 = fs_1.readFileSync(outputPath, 'utf8');
75
- if (isValidCacheContent(output_1)) {
76
- logger.debug({ fileName: fileName }, 'compileAndCacheResult(): cache hit');
77
- memoryCache.files.set(fileName, __assign(__assign({}, memoryCache.files.get(fileName)), { output: output_1 }));
78
- return output_1;
79
- }
80
- }
81
- catch (err) { }
82
- logger.debug({ fileName: fileName }, 'compileAndCacheResult(): cache miss');
83
- var output = getCompileOutput();
84
- logger.debug({ fileName: fileName, outputPath: outputPath }, 'compileAndCacheResult(): writing caches');
85
- fs_1.writeFileSync(outputPath, output);
86
- return output;
87
- }
88
- };
89
- };
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
+ }; };
90
57
  exports.createCompilerInstance = function (configs) {
91
58
  var logger = configs.logger.child({ namespace: 'ts-compiler' });
92
- var compilerOptions = configs.typescript.options, tsJest = configs.tsJest;
59
+ var compilerOptions = configs.parsedTsConfig.options, tsJest = configs.tsJest;
93
60
  var cacheDir = configs.tsCacheDir;
94
61
  var ts = configs.compilerModule;
95
62
  var extensions = ['.ts', '.tsx'];
96
63
  var memoryCache = {
97
- resolvedModules: Object.create(null),
98
64
  files: new Map(),
65
+ resolvedModules: Object.create(null),
99
66
  };
100
67
  if (compilerOptions.allowJs) {
101
68
  extensions.push('.js');
@@ -104,13 +71,13 @@ exports.createCompilerInstance = function (configs) {
104
71
  if (cacheDir) {
105
72
  mkdirp.sync(cacheDir);
106
73
  try {
107
- var resolvedModulesCache = fs_1.readFileSync(compiler_utils_1.getResolvedModulesCache(cacheDir), 'utf-8');
108
- memoryCache.resolvedModules = JSON.parse(resolvedModulesCache);
74
+ var fsMemoryCache = fs_1.readFileSync(compiler_utils_1.getResolvedModulesCache(cacheDir), 'utf-8');
75
+ memoryCache.resolvedModules = JSON.parse(fsMemoryCache);
109
76
  }
110
77
  catch (e) { }
111
78
  }
112
- configs.jest.setupFiles.concat(configs.jest.setupFilesAfterEnv).forEach(function (setupFile) {
113
- memoryCache.files.set(setupFile, {
79
+ configs.parsedTsConfig.fileNames.forEach(function (fileName) {
80
+ memoryCache.files.set(fileName, {
114
81
  version: 0,
115
82
  });
116
83
  });
@@ -124,6 +91,6 @@ exports.createCompilerInstance = function (configs) {
124
91
  else {
125
92
  compilerInstance = transpiler_1.initializeTranspilerInstance(configs, memoryCache, logger);
126
93
  }
127
- var compile = compileAndCacheResult(cacheDir, memoryCache, compilerInstance.compileFn, getExtension, logger);
94
+ var compile = compileAndCacheResult(memoryCache, compilerInstance.compileFn, getExtension, logger);
128
95
  return { cwd: configs.cwd, compile: compile, program: compilerInstance.program };
129
96
  };
@@ -21,11 +21,11 @@ var __spread = (this && this.__spread) || function () {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  var bs_logger_1 = require("bs-logger");
24
- var memoize = require("lodash.memoize");
25
24
  var path_1 = require("path");
26
25
  var constants_1 = require("../constants");
27
26
  var messages_1 = require("../util/messages");
28
27
  var compiler_utils_1 = require("./compiler-utils");
28
+ var memoize = require("lodash.memoize");
29
29
  function doTypeChecking(configs, fileName, service, logger) {
30
30
  if (configs.shouldReportDiagnostic(fileName)) {
31
31
  var diagnostics = service.getSemanticDiagnostics(fileName).concat(service.getSyntacticDiagnostics(fileName));
@@ -38,19 +38,22 @@ 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.typescript, options = _b.options, projectReferences = _b.projectReferences, fileNames = _b.fileNames;
41
+ var _b = configs.parsedTsConfig, options = _b.options, fileNames = _b.fileNames;
42
42
  var serviceHostTraceCtx = (_a = {
43
43
  namespace: 'ts:serviceHost',
44
44
  call: null
45
45
  },
46
46
  _a[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.trace,
47
47
  _a);
48
+ function isFileInCache(fileName) {
49
+ return memoryCache.files.has(fileName) && memoryCache.files.get(fileName).version !== 0;
50
+ }
48
51
  var projectVersion = 1;
49
52
  var updateMemoryCache = function (contents, fileName) {
50
- logger.debug({ fileName: fileName }, "updateMemoryCache(): update memory cache for language service");
53
+ logger.debug({ fileName: fileName }, 'updateMemoryCache(): update memory cache for language service');
51
54
  var shouldIncrementProjectVersion = false;
52
- var isFileInCache = memoryCache.files.has(fileName) && memoryCache.files.get(fileName).version !== 0;
53
- if (!isFileInCache) {
55
+ var hit = isFileInCache(fileName);
56
+ if (!hit) {
54
57
  memoryCache.files.set(fileName, {
55
58
  text: contents,
56
59
  version: 1,
@@ -61,10 +64,10 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
61
64
  var previousContents = memoryCache.files.get(fileName).text;
62
65
  if (previousContents !== contents) {
63
66
  memoryCache.files.set(fileName, {
64
- version: memoryCache.files.get(fileName).version + 1,
65
67
  text: contents,
68
+ version: memoryCache.files.get(fileName).version + 1,
66
69
  });
67
- if (isFileInCache)
70
+ if (hit)
68
71
  shouldIncrementProjectVersion = true;
69
72
  }
70
73
  if (!fileNames.includes(fileName)) {
@@ -76,7 +79,6 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
76
79
  };
77
80
  var serviceHost = {
78
81
  getProjectVersion: function () { return String(projectVersion); },
79
- getProjectReferences: function () { return projectReferences; },
80
82
  getScriptFileNames: function () { return __spread(memoryCache.files.keys()); },
81
83
  getScriptVersion: function (fileName) {
82
84
  var normalizedFileName = path_1.normalize(fileName);
@@ -84,16 +86,17 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
84
86
  return version === undefined ? undefined : String(version);
85
87
  },
86
88
  getScriptSnapshot: function (fileName) {
89
+ var _a;
87
90
  var normalizedFileName = path_1.normalize(fileName);
88
91
  var hit = memoryCache.files.has(normalizedFileName) && memoryCache.files.get(normalizedFileName).version !== 0;
89
- logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, "getScriptSnapshot():", 'cache', hit ? 'hit' : 'miss');
92
+ logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
90
93
  if (!hit) {
91
94
  memoryCache.files.set(normalizedFileName, {
92
- version: 1,
93
95
  text: ts.sys.readFile(normalizedFileName),
96
+ version: 1,
94
97
  });
95
98
  }
96
- var contents = memoryCache.files.get(normalizedFileName).text;
99
+ var contents = (_a = memoryCache.files.get(normalizedFileName)) === null || _a === void 0 ? void 0 : _a.text;
97
100
  if (contents === undefined)
98
101
  return;
99
102
  return ts.ScriptSnapshot.fromString(contents);
@@ -110,48 +113,42 @@ exports.initializeLanguageServiceInstance = function (configs, memoryCache, logg
110
113
  getDefaultLibFileName: function () { return ts.getDefaultLibFilePath(options); },
111
114
  getCustomTransformers: function () { return configs.tsCustomTransformers; },
112
115
  };
113
- logger.debug('compileUsingLanguageService(): creating language service');
116
+ logger.debug('initializeLanguageServiceInstance(): creating language service');
114
117
  var service = ts.createLanguageService(serviceHost, ts.createDocumentRegistry());
115
118
  return {
116
119
  compileFn: function (code, fileName) {
117
120
  logger.debug({ fileName: fileName }, 'compileFn(): compiling using language service');
118
121
  updateMemoryCache(code, fileName);
119
- var referencedProject = compiler_utils_1.getAndCacheProjectReference(fileName, service.getProgram(), memoryCache.files, projectReferences);
120
- if (referencedProject !== undefined) {
121
- logger.debug({ fileName: fileName }, 'compileFn(): get compile result from referenced project');
122
- return compiler_utils_1.getCompileResultFromReferencedProject(fileName, configs, memoryCache.files, referencedProject);
123
- }
124
- else {
125
- var output = service.getEmitOutput(fileName);
126
- logger.debug("compileFn(): computing diagnostics for " + fileName + " using language service");
127
- doTypeChecking(configs, fileName, service, logger);
128
- if (cacheDir) {
129
- if (compiler_utils_1.isTestFile(configs.testMatchPatterns, fileName)) {
130
- compiler_utils_1.cacheResolvedModules(fileName, code, memoryCache, service.getProgram(), cacheDir, logger);
131
- }
132
- else {
133
- Object.entries(memoryCache.resolvedModules)
134
- .filter(function (entry) {
135
- return (entry[1].modulePaths.find(function (modulePath) { return modulePath === fileName; }) && !memoryCache.files.has(entry[0]));
136
- })
137
- .forEach(function (entry) {
138
- logger.debug("compileFn(): computing diagnostics for test file that imports " + fileName + " using language service");
139
- var testFileName = entry[0];
140
- updateMemoryCache(entry[1].testFileContent, testFileName);
141
- doTypeChecking(configs, testFileName, service, logger);
142
- });
143
- }
144
- }
145
- if (output.emitSkipped) {
146
- throw new TypeError(path_1.relative(cwd, fileName) + ": Emit skipped for language service");
122
+ var output = service.getEmitOutput(fileName);
123
+ logger.debug({ fileName: fileName }, 'compileFn(): computing diagnostics using language service');
124
+ doTypeChecking(configs, fileName, service, logger);
125
+ if (cacheDir) {
126
+ if (compiler_utils_1.isTestFile(configs.testMatchPatterns, fileName)) {
127
+ compiler_utils_1.cacheResolvedModules(fileName, code, memoryCache, service.getProgram(), cacheDir, logger);
147
128
  }
148
- if (!output.outputFiles.length) {
149
- throw new TypeError(messages_1.interpolate("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`.", {
150
- file: path_1.basename(fileName),
151
- }));
129
+ else {
130
+ Object.entries(memoryCache.resolvedModules)
131
+ .filter(function (entry) {
132
+ return entry[1].modulePaths.find(function (modulePath) { return modulePath === fileName; }) && !memoryCache.files.has(entry[0]);
133
+ })
134
+ .forEach(function (entry) {
135
+ var testFileName = entry[0];
136
+ var testFileContent = entry[1].testFileContent;
137
+ logger.debug({ fileName: fileName }, 'compileFn(): computing diagnostics for test file that imports this module using language service');
138
+ updateMemoryCache(testFileContent, testFileName);
139
+ doTypeChecking(configs, testFileName, service, logger);
140
+ });
152
141
  }
153
- return [output.outputFiles[1].text, output.outputFiles[0].text];
154
142
  }
143
+ if (output.emitSkipped) {
144
+ throw new TypeError(path_1.relative(cwd, fileName) + ": Emit skipped for language service");
145
+ }
146
+ if (!output.outputFiles.length) {
147
+ throw new TypeError(messages_1.interpolate("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`.", {
148
+ file: path_1.basename(fileName),
149
+ }));
150
+ }
151
+ return [output.outputFiles[1].text, output.outputFiles[0].text];
155
152
  },
156
153
  program: service.getProgram(),
157
154
  };
@@ -1,17 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var compiler_utils_1 = require("./compiler-utils");
4
3
  exports.initializeTranspilerInstance = function (configs, memoryCache, logger) {
5
4
  logger.debug('initializeTranspilerInstance(): create typescript compiler');
6
- var _a = configs.typescript, options = _a.options, projectReferences = _a.projectReferences, fileNames = _a.fileNames;
5
+ var _a = configs.parsedTsConfig, options = _a.options, fileNames = _a.fileNames;
7
6
  var ts = configs.compilerModule;
8
- var program = projectReferences
9
- ? ts.createProgram({
10
- rootNames: fileNames,
11
- options: options,
12
- projectReferences: projectReferences,
13
- })
14
- : ts.createProgram([], options);
7
+ var program = ts.createProgram(fileNames, options);
15
8
  var updateFileInCache = function (contents, filePath) {
16
9
  var file = memoryCache.files.get(filePath);
17
10
  if (file && file.text !== contents) {
@@ -22,24 +15,17 @@ exports.initializeTranspilerInstance = function (configs, memoryCache, logger) {
22
15
  return {
23
16
  compileFn: function (code, fileName) {
24
17
  updateFileInCache(code, fileName);
25
- var referencedProject = compiler_utils_1.getAndCacheProjectReference(fileName, program, memoryCache.files, projectReferences);
26
- if (referencedProject !== undefined) {
27
- logger.debug({ fileName: fileName }, 'compileFn(): get compile result from referenced project');
28
- return compiler_utils_1.getCompileResultFromReferencedProject(fileName, configs, memoryCache.files, referencedProject);
29
- }
30
- else {
31
- logger.debug({ fileName: fileName }, 'compileFn(): compiling as isolated module');
32
- var result = ts.transpileModule(code, {
33
- fileName: fileName,
34
- transformers: configs.tsCustomTransformers,
35
- compilerOptions: options,
36
- reportDiagnostics: configs.shouldReportDiagnostic(fileName),
37
- });
38
- if (result.diagnostics && configs.shouldReportDiagnostic(fileName)) {
39
- configs.raiseDiagnostics(result.diagnostics, fileName, logger);
40
- }
41
- return [result.outputText, result.sourceMapText];
18
+ logger.debug({ fileName: fileName }, 'compileFn(): compiling as isolated module');
19
+ var result = ts.transpileModule(code, {
20
+ fileName: fileName,
21
+ transformers: configs.tsCustomTransformers,
22
+ compilerOptions: options,
23
+ reportDiagnostics: configs.shouldReportDiagnostic(fileName),
24
+ });
25
+ if (result.diagnostics && configs.shouldReportDiagnostic(fileName)) {
26
+ configs.raiseDiagnostics(result.diagnostics, fileName, logger);
42
27
  }
28
+ return [result.outputText, result.sourceMapText];
43
29
  },
44
30
  program: program,
45
31
  };
@@ -54,6 +54,7 @@ var json5 = require("json5");
54
54
  var path_1 = require("path");
55
55
  var __1 = require("..");
56
56
  var instance_1 = require("../compiler/instance");
57
+ var constants_1 = require("../constants");
57
58
  var transformers_1 = require("../transformers");
58
59
  var backports_1 = require("../util/backports");
59
60
  var get_package_version_1 = require("../util/get-package-version");
@@ -186,7 +187,13 @@ var ConfigSet = (function () {
186
187
  });
187
188
  Object.defineProperty(ConfigSet.prototype, "testMatchPatterns", {
188
189
  get: function () {
189
- return __spread(this.jest.testMatch, this.jest.testRegex);
190
+ var matchablePatterns = __spread(this.jest.testMatch, this.jest.testRegex).filter(function (pattern) {
191
+ return pattern instanceof RegExp || typeof pattern === 'string';
192
+ });
193
+ if (!matchablePatterns.length) {
194
+ matchablePatterns.push.apply(matchablePatterns, __spread(constants_1.DEFAULT_JEST_TEST_MATCH));
195
+ }
196
+ return matchablePatterns;
190
197
  },
191
198
  enumerable: true,
192
199
  configurable: true
@@ -194,13 +201,13 @@ var ConfigSet = (function () {
194
201
  Object.defineProperty(ConfigSet.prototype, "tsJest", {
195
202
  get: function () {
196
203
  var _this = this;
197
- var _a;
204
+ var _a, _b, _c;
198
205
  var parsedConfig = this.jest;
199
- var _b = parsedConfig.globals, globals = _b === void 0 ? {} : _b;
206
+ var _d = parsedConfig.globals, globals = _d === void 0 ? {} : _d;
200
207
  var options = __assign({}, globals['ts-jest']);
201
- var tsConfigOpt = options.tsConfig;
208
+ var tsConfigOpt = (_b = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : options.tsconfig) !== null && _b !== void 0 ? _b : true;
202
209
  var tsConfig;
203
- if (typeof tsConfigOpt === 'string' || tsConfigOpt == null || tsConfigOpt === true) {
210
+ if (typeof tsConfigOpt === 'string' || tsConfigOpt === true) {
204
211
  tsConfig = {
205
212
  kind: 'file',
206
213
  value: typeof tsConfigOpt === 'string' ? this.resolvePath(tsConfigOpt) : undefined,
@@ -242,7 +249,7 @@ var ConfigSet = (function () {
242
249
  };
243
250
  }
244
251
  var diagnostics;
245
- var _c = options.diagnostics, diagnosticsOpt = _c === void 0 ? true : _c;
252
+ var _e = options.diagnostics, diagnosticsOpt = _e === void 0 ? true : _e;
246
253
  var ignoreList = [exports.IGNORE_DIAGNOSTIC_CODES, process.env.TS_JEST_IGNORE_DIAGNOSTICS];
247
254
  if (diagnosticsOpt === true || diagnosticsOpt == null) {
248
255
  diagnostics = { ignoreCodes: [], pretty: true, throws: true };
@@ -272,7 +279,7 @@ var ConfigSet = (function () {
272
279
  babelConfig: babelConfig,
273
280
  diagnostics: diagnostics,
274
281
  isolatedModules: !!options.isolatedModules,
275
- compiler: (_a = options.compiler) !== null && _a !== void 0 ? _a : 'typescript',
282
+ compiler: (_c = options.compiler) !== null && _c !== void 0 ? _c : 'typescript',
276
283
  transformers: transformers,
277
284
  stringifyContentPathRegex: stringifyContentPathRegex,
278
285
  };
@@ -282,9 +289,9 @@ var ConfigSet = (function () {
282
289
  enumerable: true,
283
290
  configurable: true
284
291
  });
285
- Object.defineProperty(ConfigSet.prototype, "typescript", {
292
+ Object.defineProperty(ConfigSet.prototype, "parsedTsConfig", {
286
293
  get: function () {
287
- return this._typescript.resolved;
294
+ return this._parsedTsConfig;
288
295
  },
289
296
  enumerable: true,
290
297
  configurable: true
@@ -304,12 +311,12 @@ var ConfigSet = (function () {
304
311
  enumerable: true,
305
312
  configurable: true
306
313
  });
307
- Object.defineProperty(ConfigSet.prototype, "_typescript", {
314
+ Object.defineProperty(ConfigSet.prototype, "_parsedTsConfig", {
308
315
  get: function () {
309
316
  var tsConfig = this.tsJest.tsConfig;
310
317
  var configFilePath = tsConfig && tsConfig.kind === 'file' ? tsConfig.value : undefined;
311
318
  var result = this.readTsConfig(tsConfig && tsConfig.kind === 'inline' ? tsConfig.value : undefined, configFilePath, tsConfig == null);
312
- this.raiseDiagnostics(result.resolved.errors, configFilePath);
319
+ this.raiseDiagnostics(result.errors, configFilePath);
313
320
  this.logger.debug({ tsconfig: result }, 'normalized typescript config');
314
321
  return result;
315
322
  },
@@ -341,7 +348,7 @@ var ConfigSet = (function () {
341
348
  var babelConfig = this.tsJest.babelConfig;
342
349
  if (babelConfig == null) {
343
350
  this.logger.debug('babel is disabled');
344
- return;
351
+ return undefined;
345
352
  }
346
353
  var base = { cwd: this.cwd };
347
354
  if (babelConfig.kind === 'file') {
@@ -374,7 +381,7 @@ var ConfigSet = (function () {
374
381
  get: function () {
375
382
  var babel = this.babel;
376
383
  if (!babel)
377
- return;
384
+ return undefined;
378
385
  this.logger.debug('creating babel-jest transformer');
379
386
  return importer_1.importer.babelJest("Using \"babel-jest\" requires this package to be installed.").createTransformer(babel);
380
387
  },
@@ -428,7 +435,7 @@ var ConfigSet = (function () {
428
435
  if (((_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.fileName) && !shouldReportDiagnostic(diagnostic.file.fileName)) {
429
436
  return false;
430
437
  }
431
- return ignoreCodes.indexOf(diagnostic.code) === -1;
438
+ return !ignoreCodes.includes(diagnostic.code);
432
439
  });
433
440
  };
434
441
  },
@@ -488,14 +495,14 @@ var ConfigSet = (function () {
488
495
  get: function () {
489
496
  if (!this.jest.cache) {
490
497
  logger.debug('file caching disabled');
491
- return;
498
+ return undefined;
492
499
  }
493
500
  var cacheSuffix = sha1_1.sha1(json_1.stringify({
494
501
  version: this.compilerModule.version,
495
502
  digest: this.tsJestDigest,
496
503
  dependencies: this.projectDependencies,
497
504
  compiler: this.tsJest.compiler,
498
- compilerOptions: this.typescript.options,
505
+ compilerOptions: this.parsedTsConfig.options,
499
506
  isolatedModules: this.tsJest.isolatedModules,
500
507
  diagnostics: this.tsJest.diagnostics,
501
508
  }));
@@ -568,7 +575,7 @@ var ConfigSet = (function () {
568
575
  jest: jest,
569
576
  tsJest: this.tsJest,
570
577
  babel: this.babel,
571
- tsconfig: this.typescript.options,
578
+ tsconfig: this.parsedTsConfig.options,
572
579
  });
573
580
  },
574
581
  enumerable: true,
@@ -599,11 +606,7 @@ var ConfigSet = (function () {
599
606
  var basePath = normalize_slashes_1.normalizeSlashes(this.rootDir);
600
607
  var configFileName;
601
608
  var ts = this.compilerModule;
602
- var input;
603
- if (noProject) {
604
- input = { compilerOptions: __assign({}, compilerOptions) };
605
- }
606
- else {
609
+ if (!noProject) {
607
610
  configFileName = resolvedConfigFile
608
611
  ? normalize_slashes_1.normalizeSlashes(resolvedConfigFile)
609
612
  : ts.findConfigFile(normalize_slashes_1.normalizeSlashes(this.rootDir), ts.sys.fileExists);
@@ -611,12 +614,9 @@ var ConfigSet = (function () {
611
614
  this.logger.debug({ tsConfigFileName: configFileName }, 'readTsConfig(): reading', configFileName);
612
615
  var result_1 = ts.readConfigFile(configFileName, ts.sys.readFile);
613
616
  if (result_1.error) {
614
- return {
615
- resolved: { errors: [result_1.error], fileNames: [], options: {} },
616
- };
617
+ return { errors: [result_1.error], fileNames: [], options: {} };
617
618
  }
618
619
  config = result_1.config;
619
- input = __assign(__assign({}, result_1.config), { compilerOptions: __assign(__assign({}, (result_1.config && result_1.config.compilerOptions)), compilerOptions) });
620
620
  basePath = normalize_slashes_1.normalizeSlashes(path_1.dirname(configFileName));
621
621
  }
622
622
  }
@@ -664,7 +664,7 @@ var ConfigSet = (function () {
664
664
  }
665
665
  finally { if (e_2) throw e_2.error; }
666
666
  }
667
- return { input: input, resolved: result };
667
+ return result;
668
668
  };
669
669
  ConfigSet.prototype.resolvePath = function (inputPath, _a) {
670
670
  var _b = _a === void 0 ? {} : _a, _c = _b.throwIfMissing, throwIfMissing = _c === void 0 ? true : _c, _d = _b.nodeResolve, nodeResolve = _d === void 0 ? false : _d;
@@ -721,7 +721,7 @@ var ConfigSet = (function () {
721
721
  ], ConfigSet.prototype, "versions", null);
722
722
  __decorate([
723
723
  memoize_1.Memoize()
724
- ], ConfigSet.prototype, "_typescript", null);
724
+ ], ConfigSet.prototype, "_parsedTsConfig", null);
725
725
  __decorate([
726
726
  memoize_1.Memoize()
727
727
  ], ConfigSet.prototype, "raiseDiagnostics", null);
@@ -1,5 +1 @@
1
- export declare const LINE_FEED = "\n";
2
- export declare const EXTENSION_REGEX: RegExp;
3
- export declare const TS_TSX_REGEX: RegExp;
4
- export declare const JS_JSX_REGEX: RegExp;
5
- export declare const JSON_REGEX: RegExp;
1
+ export {};
package/dist/constants.js CHANGED
@@ -5,3 +5,4 @@ exports.EXTENSION_REGEX = /\.[^.]+$/;
5
5
  exports.TS_TSX_REGEX = /\.tsx?$/;
6
6
  exports.JS_JSX_REGEX = /\.jsx?$/;
7
7
  exports.JSON_REGEX = /\.json$/i;
8
+ exports.DEFAULT_JEST_TEST_MATCH = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
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("no matching config-set found, creating a new one");
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.typescript.options.allowJs && isJsFile) {
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/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _ts from 'typescript';
2
2
  export interface TsJestGlobalOptions {
3
3
  tsConfig?: boolean | string | _ts.CompilerOptions;
4
+ tsconfig?: boolean | string | _ts.CompilerOptions;
4
5
  packageJson?: boolean | string | object;
5
6
  isolatedModules?: boolean;
6
7
  compiler?: string;
@@ -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 = "ts-jest.log,stderr:warn";
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',
@@ -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-alpha.0",
3
+ "version": "25.5.1",
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": "run-s lint:ts lint:js",
23
- "lint:js": "node_modules/.bin/eslint . -f stylish",
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",
@@ -69,7 +65,6 @@
69
65
  "make-error": "1.x",
70
66
  "micromatch": "4.x",
71
67
  "mkdirp": "0.x",
72
- "resolve": "1.x",
73
68
  "semver": "6.x",
74
69
  "yargs-parser": "18.x"
75
70
  },
@@ -103,13 +98,18 @@
103
98
  "@types/mkdirp": "latest",
104
99
  "@types/node": "10.x",
105
100
  "@types/react": "16.x",
106
- "@types/resolve": "latest",
107
101
  "@types/semver": "latest",
108
102
  "@types/yargs": "latest",
109
103
  "@types/yargs-parser": "15.x",
104
+ "@typescript-eslint/eslint-plugin": "latest",
105
+ "@typescript-eslint/parser": "latest",
110
106
  "conventional-changelog-cli": "2.x",
111
107
  "cross-spawn": "latest",
112
108
  "eslint": "latest",
109
+ "eslint-config-prettier": "latest",
110
+ "eslint-plugin-jest": "latest",
111
+ "eslint-plugin-jsdoc": "latest",
112
+ "eslint-plugin-prettier": "latest",
113
113
  "fs-extra": "8.x",
114
114
  "glob-gitignore": "latest",
115
115
  "husky": "3.x",
@@ -121,14 +121,11 @@
121
121
  "npm-run-all": "latest",
122
122
  "prettier": "1.x",
123
123
  "source-map": "latest",
124
- "tslint": "latest",
125
- "tslint-config-prettier": "latest",
126
- "tslint-plugin-prettier": "latest",
127
124
  "typescript": "3.x"
128
125
  },
129
126
  "lint-staged": {
130
127
  "*.{ts,tsx}": [
131
- "tslint --fix",
128
+ "eslint --fix",
132
129
  "git add"
133
130
  ],
134
131
  "*.{js,jsx}": [
package/preprocessor.js CHANGED
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line no-console
1
2
  console.warn(
2
3
  'ts-jest[main] (WARN) Replace any occurrences of "ts-jest/dist/preprocessor.js" or ' +
3
4
  ' "<rootDir>/node_modules/ts-jest/preprocessor.js"' +
package/presets/index.js CHANGED
@@ -1,13 +1,20 @@
1
1
  const create = require('./create')
2
2
 
3
3
  module.exports = {
4
- get defaults() { return create() },
5
- get jsWithTs() { return create({ allowJs: true }) },
4
+ get defaults() {
5
+ return create()
6
+ },
7
+ get jsWithTs() {
8
+ return create({ allowJs: true })
9
+ },
6
10
  get jsWithBabel() {
7
- return create({ allowJs: false }, {
8
- transform: {
9
- '^.+\\.jsx?$': 'babel-jest',
10
- },
11
- })
11
+ return create(
12
+ { allowJs: false },
13
+ {
14
+ transform: {
15
+ '^.+\\.jsx?$': 'babel-jest',
16
+ },
17
+ }
18
+ )
12
19
  },
13
20
  }
@@ -1,66 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <JSCodeStyleSettings version="0">
4
- <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
5
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
6
- <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
7
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
8
- <option name="USE_DOUBLE_QUOTES" value="false" />
9
- <option name="FORCE_QUOTE_STYlE" value="true" />
10
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
11
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
12
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
13
- <option name="SPACES_WITHIN_INTERPOLATION_EXPRESSIONS" value="true" />
14
- </JSCodeStyleSettings>
15
- <TypeScriptCodeStyleSettings version="0">
16
- <option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
17
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
18
- <option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACKETS" value="true" />
19
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
20
- <option name="USE_DOUBLE_QUOTES" value="false" />
21
- <option name="FORCE_QUOTE_STYlE" value="true" />
22
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
23
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
24
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
25
- <option name="SPACE_WITHIN_TYPE_ASSERTION" value="true" />
26
- <option name="SPACES_WITHIN_INTERPOLATION_EXPRESSIONS" value="true" />
27
- <option name="IMPORT_SORT_MODULE_NAME" value="true" />
28
- </TypeScriptCodeStyleSettings>
29
- <codeStyleSettings language="HTML">
30
- <indentOptions>
31
- <option name="CONTINUATION_INDENT_SIZE" value="4" />
32
- </indentOptions>
33
- </codeStyleSettings>
34
- <codeStyleSettings language="JSON">
35
- <indentOptions>
36
- <option name="TAB_SIZE" value="2" />
37
- </indentOptions>
38
- </codeStyleSettings>
39
- <codeStyleSettings language="JavaScript">
40
- <option name="INDENT_CASE_FROM_SWITCH" value="false" />
41
- <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
42
- <option name="ALIGN_MULTILINE_FOR" value="false" />
43
- <option name="SPACE_WITHIN_BRACKETS" value="true" />
44
- <option name="SOFT_MARGINS" value="120" />
45
- <indentOptions>
46
- <option name="INDENT_SIZE" value="2" />
47
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
48
- <option name="TAB_SIZE" value="2" />
49
- </indentOptions>
50
- </codeStyleSettings>
51
- <codeStyleSettings language="TypeScript">
52
- <option name="SPACE_WITHIN_BRACKETS" value="true" />
53
- <option name="IF_BRACE_FORCE" value="1" />
54
- <option name="DOWHILE_BRACE_FORCE" value="1" />
55
- <option name="WHILE_BRACE_FORCE" value="1" />
56
- <option name="FOR_BRACE_FORCE" value="1" />
57
- <option name="SOFT_MARGINS" value="120" />
58
- <indentOptions>
59
- <option name="INDENT_SIZE" value="2" />
60
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
61
- <option name="TAB_SIZE" value="2" />
62
- <option name="SMART_TABS" value="true" />
63
- </indentOptions>
64
- </codeStyleSettings>
65
- </code_scheme>
66
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,7 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- <inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
6
- </profile>
7
- </component>
package/.idea/misc.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- </project>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/ts-jest.iml" filepath="$PROJECT_DIR$/.idea/ts-jest.iml" />
6
- </modules>
7
- </component>
8
- </project>
package/.idea/ts-jest.iml DELETED
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
@@ -1,160 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="BranchesTreeState">
4
- <expand>
5
- <path>
6
- <item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
7
- <item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
8
- </path>
9
- <path>
10
- <item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
11
- <item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
12
- </path>
13
- <path>
14
- <item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
15
- <item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
16
- <item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
17
- </path>
18
- </expand>
19
- <select />
20
- </component>
21
- <component name="ChangeListManager">
22
- <list default="true" id="42f3cd19-a49c-408b-b305-e7ce31ab9a6f" name="Default Changelist" comment="chore: cut release 25.5.0-alpha.0" />
23
- <option name="SHOW_DIALOG" value="false" />
24
- <option name="HIGHLIGHT_CONFLICTS" value="true" />
25
- <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
26
- <option name="LAST_RESOLUTION" value="IGNORE" />
27
- </component>
28
- <component name="Git.Settings">
29
- <option name="RECENT_BRANCH_BY_REPOSITORY">
30
- <map>
31
- <entry key="$PROJECT_DIR$" value="master" />
32
- </map>
33
- </option>
34
- <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
35
- </component>
36
- <component name="ProjectId" id="1atT8QlNqhI630eSTMKXiikJWMW" />
37
- <component name="ProjectViewState">
38
- <option name="autoscrollFromSource" value="true" />
39
- <option name="autoscrollToSource" value="true" />
40
- <option name="hideEmptyMiddlePackages" value="true" />
41
- <option name="showLibraryContents" value="true" />
42
- </component>
43
- <component name="PropertiesComponent">
44
- <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
45
- <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
46
- <property name="WebServerToolWindowFactoryState" value="false" />
47
- <property name="last_opened_file_path" value="$PROJECT_DIR$" />
48
- <property name="node.js.detected.package.eslint" value="true" />
49
- <property name="node.js.detected.package.tslint" value="true" />
50
- <property name="node.js.path.for.package.eslint" value="project" />
51
- <property name="node.js.path.for.package.tslint" value="project" />
52
- <property name="node.js.selected.package.eslint" value="(autodetect)" />
53
- <property name="node.js.selected.package.tslint" value="(autodetect)" />
54
- <property name="nodejs_package_manager_path" value="npm" />
55
- <property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
56
- </component>
57
- <component name="RunManager" selected="npm.changelog">
58
- <configuration name="changelog" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
59
- <package-json value="$PROJECT_DIR$/package.json" />
60
- <command value="run" />
61
- <scripts>
62
- <script value="changelog" />
63
- </scripts>
64
- <node-interpreter value="project" />
65
- <envs />
66
- <method v="2" />
67
- </configuration>
68
- <configuration name="prepare" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
69
- <package-json value="$PROJECT_DIR$/package.json" />
70
- <command value="run" />
71
- <scripts>
72
- <script value="prepare" />
73
- </scripts>
74
- <node-interpreter value="project" />
75
- <envs />
76
- <method v="2" />
77
- </configuration>
78
- <recent_temporary>
79
- <list>
80
- <item itemvalue="npm.changelog" />
81
- <item itemvalue="npm.prepare" />
82
- </list>
83
- </recent_temporary>
84
- </component>
85
- <component name="SvnConfiguration">
86
- <configuration />
87
- </component>
88
- <component name="TaskManager">
89
- <task active="true" id="Default" summary="Default task">
90
- <changelist id="42f3cd19-a49c-408b-b305-e7ce31ab9a6f" name="Default Changelist" comment="" />
91
- <created>1587553730266</created>
92
- <option name="number" value="Default" />
93
- <option name="presentableId" value="Default" />
94
- <updated>1587553730266</updated>
95
- <workItem from="1587553731980" duration="723000" />
96
- <workItem from="1587559531320" duration="414000" />
97
- </task>
98
- <task id="LOCAL-00001" summary="chore: cut release 25.5.0-alpha.0">
99
- <created>1587559667898</created>
100
- <option name="number" value="00001" />
101
- <option name="presentableId" value="LOCAL-00001" />
102
- <option name="project" value="LOCAL" />
103
- <updated>1587559667898</updated>
104
- </task>
105
- <task id="LOCAL-00002" summary="chore: cut release 25.5.0-alpha.0">
106
- <created>1587559936079</created>
107
- <option name="number" value="00002" />
108
- <option name="presentableId" value="LOCAL-00002" />
109
- <option name="project" value="LOCAL" />
110
- <updated>1587559936079</updated>
111
- </task>
112
- <option name="localTasksCounter" value="3" />
113
- <servers />
114
- </component>
115
- <component name="TypeScriptGeneratedFilesManager">
116
- <option name="version" value="2" />
117
- </component>
118
- <component name="Vcs.Log.Tabs.Properties">
119
- <option name="TAB_STATES">
120
- <map>
121
- <entry key="MAIN">
122
- <value>
123
- <State />
124
- </value>
125
- </entry>
126
- </map>
127
- </option>
128
- <option name="oldMeFiltersMigrated" value="true" />
129
- </component>
130
- <component name="VcsManagerConfiguration">
131
- <MESSAGE value="chore: cut release 25.5.0-alpha.0" />
132
- <option name="LAST_COMMIT_MESSAGE" value="chore: cut release 25.5.0-alpha.0" />
133
- </component>
134
- <component name="WindowStateProjectService">
135
- <state width="1659" height="249" key="GridCell.Tab.0.bottom" timestamp="1587559888254">
136
- <screen x="0" y="23" width="1680" height="947" />
137
- </state>
138
- <state width="1659" height="249" key="GridCell.Tab.0.bottom/0.23.1680.947@0.23.1680.947" timestamp="1587559888254" />
139
- <state width="1659" height="249" key="GridCell.Tab.0.center" timestamp="1587559888253">
140
- <screen x="0" y="23" width="1680" height="947" />
141
- </state>
142
- <state width="1659" height="249" key="GridCell.Tab.0.center/0.23.1680.947@0.23.1680.947" timestamp="1587559888253" />
143
- <state width="1659" height="249" key="GridCell.Tab.0.left" timestamp="1587559888253">
144
- <screen x="0" y="23" width="1680" height="947" />
145
- </state>
146
- <state width="1659" height="249" key="GridCell.Tab.0.left/0.23.1680.947@0.23.1680.947" timestamp="1587559888253" />
147
- <state width="1659" height="249" key="GridCell.Tab.0.right" timestamp="1587559888254">
148
- <screen x="0" y="23" width="1680" height="947" />
149
- </state>
150
- <state width="1659" height="249" key="GridCell.Tab.0.right/0.23.1680.947@0.23.1680.947" timestamp="1587559888254" />
151
- <state x="440" y="232" key="Vcs.Push.Dialog.v2" timestamp="1587559940193">
152
- <screen x="0" y="23" width="1680" height="947" />
153
- </state>
154
- <state x="440" y="232" key="Vcs.Push.Dialog.v2/0.23.1680.947@0.23.1680.947" timestamp="1587559940193" />
155
- <state x="556" y="277" key="git4idea.merge.GitPullDialog" timestamp="1587559687017">
156
- <screen x="0" y="23" width="1680" height="947" />
157
- </state>
158
- <state x="556" y="277" key="git4idea.merge.GitPullDialog/0.23.1680.947@0.23.1680.947" timestamp="1587559687017" />
159
- </component>
160
- </project>