ts-jest 25.2.0 → 25.2.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
- 35ae96df88417ec4b77b95e0ac77f17d1e091ad1
1
+ 6982d3f1883cd9adc2334b36b70c6625ec327569
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ <a name="25.2.1"></a>
2
+ ## [25.2.1](https://github.com/kulshekhar/ts-jest/compare/v25.2.0...v25.2.1) (2020-02-19)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **compiler:** allow transformation of typescript files in node_modules ([#1385](https://github.com/kulshekhar/ts-jest/issues/1385)) ([814405e](https://github.com/kulshekhar/ts-jest/commit/814405e))
8
+ * **transformer:** add deepUnmock to hoist method list ([#1372](https://github.com/kulshekhar/ts-jest/issues/1372)) ([0fbbc00](https://github.com/kulshekhar/ts-jest/commit/0fbbc00))
9
+ * **util:** use resolve package typescript package in yarn workspaces ([#1377](https://github.com/kulshekhar/ts-jest/issues/1377)) ([a63808c](https://github.com/kulshekhar/ts-jest/commit/a63808c))
10
+
11
+
12
+
1
13
  <a name="25.2.0"></a>
2
14
  # [25.2.0](https://github.com/kulshekhar/ts-jest/compare/v25.1.0...v25.2.0) (2020-02-03)
3
15
 
package/dist/compiler.js CHANGED
@@ -42,6 +42,7 @@ var bs_logger_1 = require("bs-logger");
42
42
  var bufferFrom = require("buffer-from");
43
43
  var stableStringify = require("fast-json-stable-stringify");
44
44
  var fs_1 = require("fs");
45
+ var build_1 = require("jest-config/build");
45
46
  var memoize = require("lodash.memoize");
46
47
  var mkdirp = require("mkdirp");
47
48
  var path_1 = require("path");
@@ -112,6 +113,10 @@ function createCompiler(configs) {
112
113
  _b.call = null,
113
114
  _b);
114
115
  var serviceHostTraceCtx = __assign(__assign({}, serviceHostDebugCtx), (_c = {}, _c[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.trace, _c));
116
+ var transformIgnorePattern = (configs.jest.transformIgnorePatterns || build_1.defaults.transformIgnorePatterns)
117
+ .map(function (pattern) { return build_1.replaceRootDirInPath(configs.rootDir, pattern); })
118
+ .join('|');
119
+ var transformIgnoreRegExp_1 = new RegExp(transformIgnorePattern);
115
120
  var serviceHost = {
116
121
  getScriptFileNames: function () { return Object.keys(memoryCache.versions); },
117
122
  getScriptVersion: function (fileName) {
@@ -161,6 +166,13 @@ function createCompiler(configs) {
161
166
  if (output.emitSkipped) {
162
167
  throw new TypeError(path_1.relative(cwd, fileName) + ": Emit skipped");
163
168
  }
169
+ if (output.outputFiles.length === 0 && !transformIgnoreRegExp_1.test(fileName)) {
170
+ var normalizedFileName = path_1.normalize(fileName);
171
+ if (!hasOwn.call(memoryCache.versions, normalizedFileName)) {
172
+ memoryCache.versions[normalizedFileName] = 0;
173
+ }
174
+ output = service_1.getEmitOutput(fileName);
175
+ }
164
176
  if (output.outputFiles.length === 0) {
165
177
  throw new TypeError(messages_1.interpolate(messages_1.Errors.UnableToRequireDefinitionFile, {
166
178
  file: path_1.basename(fileName),
@@ -176,9 +176,10 @@ var ConfigSet = (function () {
176
176
  });
177
177
  Object.defineProperty(ConfigSet.prototype, "jest", {
178
178
  get: function () {
179
+ var _a;
179
180
  var config = backports_1.backportJestConfig(this.logger, this._jestConfig);
180
181
  if (this.parentOptions) {
181
- var globals = config.globals || (config.globals = {});
182
+ var globals = (_a = config.globals, (_a !== null && _a !== void 0 ? _a : {}));
182
183
  globals['ts-jest'] = __assign(__assign({}, this.parentOptions), globals['ts-jest']);
183
184
  }
184
185
  this.logger.debug({ jestConfig: config }, 'normalized jest config');
@@ -298,7 +299,8 @@ var ConfigSet = (function () {
298
299
  modules.push('@babel/core', 'babel-jest');
299
300
  }
300
301
  return modules.reduce(function (map, name) {
301
- map[name] = get_package_version_1.getPackageVersion(name) || '-';
302
+ var _a;
303
+ map[name] = (_a = get_package_version_1.getPackageVersion(name), (_a !== null && _a !== void 0 ? _a : '-'));
302
304
  return map;
303
305
  }, { 'ts-jest': __1.version });
304
306
  },
@@ -324,7 +326,7 @@ var ConfigSet = (function () {
324
326
  return function (diagnostics, filePath, logger) {
325
327
  if (logger === void 0) { logger = _this.logger; }
326
328
  var filteredDiagnostics = filterDiagnostics(diagnostics, filePath);
327
- if (filteredDiagnostics.length === 0)
329
+ if (!filteredDiagnostics.length)
328
330
  return;
329
331
  var error = createTsError(filteredDiagnostics);
330
332
  var importantCategories = [DiagnosticCategory.Warning, DiagnosticCategory.Error];
@@ -425,7 +427,8 @@ var ConfigSet = (function () {
425
427
  if (filePath && !shouldReportDiagnostic(filePath))
426
428
  return [];
427
429
  return diagnostics.filter(function (diagnostic) {
428
- if (diagnostic.file && diagnostic.file.fileName && !shouldReportDiagnostic(diagnostic.file.fileName)) {
430
+ var _a;
431
+ if (((_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.fileName) && !shouldReportDiagnostic(diagnostic.file.fileName)) {
429
432
  return false;
430
433
  }
431
434
  return ignoreCodes.indexOf(diagnostic.code) === -1;
@@ -548,13 +551,6 @@ var ConfigSet = (function () {
548
551
  enumerable: true,
549
552
  configurable: true
550
553
  });
551
- Object.defineProperty(ConfigSet.prototype, "isDoctoring", {
552
- get: function () {
553
- return !!process.env.TS_JEST_DOCTOR;
554
- },
555
- enumerable: true,
556
- configurable: true
557
- });
558
554
  Object.defineProperty(ConfigSet.prototype, "tsJestDigest", {
559
555
  get: function () {
560
556
  return __1.digest;
@@ -21,20 +21,21 @@ 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 HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock'];
24
+ var HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock', 'deepUnmock'];
25
25
  exports.name = 'hoisting-jest-mock';
26
26
  exports.version = 1;
27
27
  function factory(cs) {
28
28
  var logger = cs.logger.child({ namespace: 'ts-hoisting' });
29
29
  var ts = cs.compilerModule;
30
+ function shouldHoistExpression(expression) {
31
+ return (ts.isCallExpression(expression) &&
32
+ ts.isPropertyAccessExpression(expression.expression) &&
33
+ HOIST_METHODS.includes(expression.expression.name.text) &&
34
+ ((ts.isIdentifier(expression.expression.expression) && expression.expression.expression.text === 'jest') ||
35
+ shouldHoistExpression(expression.expression.expression)));
36
+ }
30
37
  function shouldHoistNode(node) {
31
- return (ts.isExpressionStatement(node) &&
32
- ts.isCallExpression(node.expression) &&
33
- ts.isPropertyAccessExpression(node.expression.expression) &&
34
- ts.isIdentifier(node.expression.expression.expression) &&
35
- node.expression.expression.expression.text === 'jest' &&
36
- ts.isIdentifier(node.expression.expression.name) &&
37
- HOIST_METHODS.includes(node.expression.expression.name.text));
38
+ return ts.isExpressionStatement(node) && shouldHoistExpression(node.expression);
38
39
  }
39
40
  function createVisitor(ctx, _) {
40
41
  var level = 0;
package/dist/types.d.ts CHANGED
@@ -107,7 +107,4 @@ export interface AstTransformerDesc {
107
107
  version: number;
108
108
  factory(cs: ConfigSet): TransformerFactory<SourceFile>;
109
109
  }
110
- export interface IPackageJson {
111
- main: string;
112
- }
113
110
  export {};
@@ -177,15 +177,20 @@ function requireWrapper(moduleName) {
177
177
  }
178
178
  var result = { exists: exists, path: path, given: moduleName };
179
179
  try {
180
- result.exports = requireModule(moduleName);
180
+ result.exports = requireModule(path);
181
181
  }
182
182
  catch (error) {
183
- result.error = error;
183
+ try {
184
+ result.exports = requireModule(moduleName);
185
+ }
186
+ catch (error) {
187
+ result.error = error;
188
+ }
184
189
  }
185
190
  return result;
186
191
  }
187
192
  var requireModule = function (mod) { return require(mod); };
188
- var resolveModule = function (mod) { return require.resolve(mod); };
193
+ var resolveModule = function (mod) { return require.resolve(mod, { paths: [process.cwd(), __dirname] }); };
189
194
  function __requireModule(localRequire, localResolve) {
190
195
  requireModule = localRequire;
191
196
  resolveModule = localResolve;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "25.2.0",
3
+ "version": "25.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": "cli.js",
@@ -18,6 +18,7 @@
18
18
  "test:e2e:update-snaphots": "node scripts/e2e.js --updateSnapshot",
19
19
  "test:unit": "node_modules/.bin/jest",
20
20
  "test:external": "node scripts/test-external-project.js",
21
+ "test:monorepo": "npm run test:external monorepo",
21
22
  "lint": "run-s lint:ts lint:js",
22
23
  "lint:js": "node_modules/.bin/eslint . -f stylish",
23
24
  "lint:ts": "node_modules/.bin/tslint -t stylish --project .",
@@ -50,7 +51,9 @@
50
51
  ],
51
52
  "author": "Kulshekhar Kabra <kulshekhar@users.noreply.github.com> (https://github.com/kulshekhar)",
52
53
  "contributors": [
53
- "Huafu Gandon <huafu.gandon@gmail.com> (https://github.com/huafu)"
54
+ "Huafu Gandon <huafu.gandon@gmail.com> (https://github.com/huafu)",
55
+ "Anh Pham <anhpnnd@gmail.com> (https://github.com/ahnpnl)",
56
+ "Gustav Wengel <gustavwengel@gmail.com> (https://github.com/GeeWee)"
54
57
  ],
55
58
  "license": "MIT",
56
59
  "bugs": {
@@ -61,13 +64,13 @@
61
64
  "bs-logger": "0.x",
62
65
  "buffer-from": "1.x",
63
66
  "fast-json-stable-stringify": "2.x",
64
- "lodash.memoize": "4.x",
65
67
  "json5": "2.x",
68
+ "lodash.memoize": "4.x",
66
69
  "make-error": "1.x",
67
70
  "mkdirp": "0.x",
68
71
  "resolve": "1.x",
69
72
  "semver": "^5.5",
70
- "yargs-parser": "10.x"
73
+ "yargs-parser": "^16.1.0"
71
74
  },
72
75
  "peerDependencies": {
73
76
  "jest": ">=25 <26"
@@ -99,12 +102,13 @@
99
102
  "@types/resolve": "latest",
100
103
  "@types/semver": "latest",
101
104
  "@types/yargs": "latest",
105
+ "@types/yargs-parser": "^15.0.0",
102
106
  "conventional-changelog-cli": "2.x",
103
107
  "cross-spawn": "latest",
104
108
  "eslint": "latest",
105
109
  "fs-extra": "latest",
106
110
  "glob-gitignore": "latest",
107
- "husky": "1.x",
111
+ "husky": "3.x",
108
112
  "jest": "25.x",
109
113
  "js-yaml": "latest",
110
114
  "lint-staged": "latest",