ts-jest 24.0.1 → 24.3.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 CHANGED
@@ -1 +1 @@
1
- a8aa81109806244e6aec89a7757a9d4d76a38fef
1
+ e2c1d8a30f4a1fa691815687145c378201aba86a
package/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ <a name="24.3.0"></a>
2
+ # [24.3.0](https://github.com/kulshekhar/ts-jest/compare/v24.2.0...v24.3.0) (2020-01-07)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **config:** support babel config file path as string ([#1332](https://github.com/kulshekhar/ts-jest/issues/1332)) ([78a53c2](https://github.com/kulshekhar/ts-jest/commit/78a53c2))
8
+
9
+
10
+
11
+ <a name="24.2.0"></a>
12
+ # [24.2.0](https://github.com/kulshekhar/ts-jest/compare/v24.1.0...v24.2.0) (2019-11-22)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * typescript serviceHost cache miss on Windows operating systems ([26ee731](https://github.com/kulshekhar/ts-jest/commit/26ee731))
18
+ * **compiler:** pass filename to sha function instead of file extension ([ac1ac97](https://github.com/kulshekhar/ts-jest/commit/ac1ac97))
19
+ * **transformers:** hoist jest.enableAutomock and jest.disableAutomock ([ac50bc3](https://github.com/kulshekhar/ts-jest/commit/ac50bc3))
20
+
21
+
22
+
23
+ <a name="24.1.0"></a>
24
+ # [24.1.0](https://github.com/kulshekhar/ts-jest/compare/v24.0.2...v24.1.0) (2019-09-12)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * [#825](https://github.com/kulshekhar/ts-jest/issues/825) handle symlinked modules (ala pnpm) correctly ([e190b23](https://github.com/kulshekhar/ts-jest/commit/e190b23))
30
+ * handle tsBuildInfoFile option ([f9583e9](https://github.com/kulshekhar/ts-jest/commit/f9583e9)), closes [#1095](https://github.com/kulshekhar/ts-jest/issues/1095)
31
+ * **perf:** add cache for fs calls ([#908](https://github.com/kulshekhar/ts-jest/issues/908)) ([3dada81](https://github.com/kulshekhar/ts-jest/commit/3dada81))
32
+ * **types:** unforce esModuleInterop in tsconfig.json ([c2d39b6](https://github.com/kulshekhar/ts-jest/commit/c2d39b6))
33
+
34
+
35
+
36
+ <a name="24.0.2"></a>
37
+ ## [24.0.2](https://github.com/kulshekhar/ts-jest/compare/v24.0.1...v24.0.2) (2019-04-05)
38
+
39
+
40
+
1
41
  <a name="24.0.1"></a>
2
42
  ## [24.0.1](https://github.com/kulshekhar/ts-jest/compare/v24.0.0...v24.0.1) (2019-03-30)
3
43
 
@@ -200,26 +240,29 @@
200
240
 
201
241
  ### Bug Fixes
202
242
 
203
- * typos + node 6 compat ([0ed1587](https://github.com/kulshekhar/ts-jest/commit/0ed1587))
204
- * **ci:** can't use runInBand for e2e: cache collision ([db650f4](https://github.com/kulshekhar/ts-jest/commit/db650f4))
205
- * jest 22 did not have default config ([cbaddc3](https://github.com/kulshekhar/ts-jest/commit/cbaddc3))
206
- * **ci:** do not run e2e sub-tests in band ([18ad865](https://github.com/kulshekhar/ts-jest/commit/18ad865))
207
- * **ci:** ensure npm is present with ci ([edb6eda](https://github.com/kulshekhar/ts-jest/commit/edb6eda))
208
- * **logger:** removes cyclic imports ([5ef980f](https://github.com/kulshekhar/ts-jest/commit/5ef980f))
209
243
  * babel-config + adds test ([12146c3](https://github.com/kulshekhar/ts-jest/commit/12146c3))
210
- * **tests:** CI fixes ([34a41ea](https://github.com/kulshekhar/ts-jest/commit/34a41ea))
211
244
  * fixes js style to be node < 10 compatible ([83d7517](https://github.com/kulshekhar/ts-jest/commit/83d7517))
212
245
  * hoisting per level + memoize fix ([31847b0](https://github.com/kulshekhar/ts-jest/commit/31847b0))
246
+ * jest 22 did not have default config ([cbaddc3](https://github.com/kulshekhar/ts-jest/commit/cbaddc3))
247
+ * makes node 6 happy ([f6f82b8](https://github.com/kulshekhar/ts-jest/commit/f6f82b8))
213
248
  * makes node6 happy ([f170285](https://github.com/kulshekhar/ts-jest/commit/f170285))
249
+ * makes window happy ([36fbebe](https://github.com/kulshekhar/ts-jest/commit/36fbebe))
250
+ * **ci:** can't use runInBand for e2e: cache collision ([db650f4](https://github.com/kulshekhar/ts-jest/commit/db650f4))
251
+ * **ci:** do not run e2e sub-tests in band ([18ad865](https://github.com/kulshekhar/ts-jest/commit/18ad865))
252
+ * **ci:** ensure npm is present with ci ([edb6eda](https://github.com/kulshekhar/ts-jest/commit/edb6eda))
253
+ * **logger:** removes cyclic imports ([5ef980f](https://github.com/kulshekhar/ts-jest/commit/5ef980f))
254
+ * **tests:** detect npm version to use or not ci ([683a1e5](https://github.com/kulshekhar/ts-jest/commit/683a1e5))
214
255
  * node 6 unhappy again... ([703ad0b](https://github.com/kulshekhar/ts-jest/commit/703ad0b))
256
+ * **tests:** CI fixes ([34a41ea](https://github.com/kulshekhar/ts-jest/commit/34a41ea))
257
+ * **tests:** do not use babel in our tests + new API for simple ([3e4de3e](https://github.com/kulshekhar/ts-jest/commit/3e4de3e))
215
258
  * normalizes bundle hash on any node version ([ce7afaf](https://github.com/kulshekhar/ts-jest/commit/ce7afaf))
259
+ * npm coming with node 6 doesn't talk `ci` ([b87198d](https://github.com/kulshekhar/ts-jest/commit/b87198d))
216
260
  * source maps ([89a30c9](https://github.com/kulshekhar/ts-jest/commit/89a30c9))
261
+ * typos + node 6 compat ([0ed1587](https://github.com/kulshekhar/ts-jest/commit/0ed1587))
262
+ * **tests:** more sanitizing for windows compat ([faae274](https://github.com/kulshekhar/ts-jest/commit/faae274))
217
263
  * updates templates ([f2e1da2](https://github.com/kulshekhar/ts-jest/commit/f2e1da2))
218
264
  * uses cross-platform spawn + fix pkg versions ([ac1599c](https://github.com/kulshekhar/ts-jest/commit/ac1599c))
219
265
  * we are not writing files, use normalized EOL ([47fff43](https://github.com/kulshekhar/ts-jest/commit/47fff43))
220
- * **tests:** detect npm version to use or not ci ([683a1e5](https://github.com/kulshekhar/ts-jest/commit/683a1e5))
221
- * **tests:** do not use babel in our tests + new API for simple ([3e4de3e](https://github.com/kulshekhar/ts-jest/commit/3e4de3e))
222
- * **tests:** more sanitizing for windows compat ([faae274](https://github.com/kulshekhar/ts-jest/commit/faae274))
223
266
 
224
267
 
225
268
  ### Features
@@ -246,6 +289,7 @@
246
289
  * **babel:** uses babel-jest cache key as part of ours ([f51c4a7](https://github.com/kulshekhar/ts-jest/commit/f51c4a7))
247
290
  * do not type check if fileName doesn't match ([cc45adc](https://github.com/kulshekhar/ts-jest/commit/cc45adc))
248
291
  * faster tests ([37a0187](https://github.com/kulshekhar/ts-jest/commit/37a0187))
292
+ * improves speed of local test after 1st run ([cc04021](https://github.com/kulshekhar/ts-jest/commit/cc04021))
249
293
  * more cleaning ([c48f7b8](https://github.com/kulshekhar/ts-jest/commit/c48f7b8))
250
294
  * trying to improve travis-ci conf ([e4b4d95](https://github.com/kulshekhar/ts-jest/commit/e4b4d95))
251
295
  * **cache:** share config-sets for parallel test running ([090ca7b](https://github.com/kulshekhar/ts-jest/commit/090ca7b))
@@ -262,27 +306,23 @@
262
306
  * **html:** correctly transforms html source when needed ([9a2d74f](https://github.com/kulshekhar/ts-jest/commit/9a2d74f))
263
307
  * **lint:** fixes tslint script & lint issues ([60ab36e](https://github.com/kulshekhar/ts-jest/commit/60ab36e))
264
308
  * **package:** update fs-extra to version 6.0.1 ([7e73536](https://github.com/kulshekhar/ts-jest/commit/7e73536))
265
- * **package:** update pkg-dir to version 3.0.0 ([3fb8f9f](https://github.com/kulshekhar/ts-jest/commit/3fb8f9f))
266
- * **package:** update yargs to version 12.0.1 ([390ffcd](https://github.com/kulshekhar/ts-jest/commit/390ffcd))
267
- * **source-maps:** fix source maps options/calls ([76e27c1](https://github.com/kulshekhar/ts-jest/commit/76e27c1))
268
309
  * allow (but deprecate) use of old preprocessor.js ([a65079f](https://github.com/kulshekhar/ts-jest/commit/a65079f))
269
310
  * big refactor + fixes (mainly cache key + coverage) ([e46caae](https://github.com/kulshekhar/ts-jest/commit/e46caae))
270
311
  * fixes coverage and tests ([09500c2](https://github.com/kulshekhar/ts-jest/commit/09500c2))
271
312
  * gracefully load [@babel](https://github.com/babel)/core or babel-core ([98b2410](https://github.com/kulshekhar/ts-jest/commit/98b2410))
272
313
  * hack for babel < 6 so that breakpoints do work ([90c74ef](https://github.com/kulshekhar/ts-jest/commit/90c74ef)), closes [#627](https://github.com/kulshekhar/ts-jest/issues/627)
273
- * makes node 6 happy ([f6f82b8](https://github.com/kulshekhar/ts-jest/commit/f6f82b8))
274
- * makes window happy ([36fbebe](https://github.com/kulshekhar/ts-jest/commit/36fbebe))
275
- * npm coming with node 6 doesn't talk `ci` ([b87198d](https://github.com/kulshekhar/ts-jest/commit/b87198d))
314
+ * **package:** update pkg-dir to version 3.0.0 ([3fb8f9f](https://github.com/kulshekhar/ts-jest/commit/3fb8f9f))
315
+ * **package:** update yargs to version 12.0.1 ([390ffcd](https://github.com/kulshekhar/ts-jest/commit/390ffcd))
276
316
  * resolves correctly config file path (fix [#636](https://github.com/kulshekhar/ts-jest/issues/636)) ([5ab100c](https://github.com/kulshekhar/ts-jest/commit/5ab100c))
277
317
  * test rootDir to handle preset-angular ([8a6a8f7](https://github.com/kulshekhar/ts-jest/commit/8a6a8f7))
278
318
  * Typo in utils.ts ([#534](https://github.com/kulshekhar/ts-jest/issues/534)) ([a650260](https://github.com/kulshekhar/ts-jest/commit/a650260))
319
+ * **source-maps:** fix source maps options/calls ([76e27c1](https://github.com/kulshekhar/ts-jest/commit/76e27c1))
279
320
  * wrong error message ([c955083](https://github.com/kulshekhar/ts-jest/commit/c955083))
280
321
 
281
322
 
282
323
  ### Performance Improvements
283
324
 
284
325
  * do not hash cache key, jest does it underneath ([fbe4f1f](https://github.com/kulshekhar/ts-jest/commit/fbe4f1f))
285
- * improves speed of local test after 1st run ([cc04021](https://github.com/kulshekhar/ts-jest/commit/cc04021))
286
326
 
287
327
 
288
328
 
package/README.md CHANGED
@@ -46,7 +46,7 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduc
46
46
 
47
47
  ## Versioning
48
48
 
49
- We **DO NOT** use [SemVer](http://semver.org/) for versioning. Tho you can think about SemVer when reading our version, except our major number follows the one of Jest. For the versions available, see the [tags on this repository](https://github.com/kulshekhar/ts-jest/tags).
49
+ We **DO NOT** use [SemVer](http://semver.org/) for versioning. Though you can think about SemVer when reading our version, except our major number follows the one of Jest. For the versions available, see the [tags on this repository](https://github.com/kulshekhar/ts-jest/tags).
50
50
 
51
51
  ## Authors/maintainers
52
52
 
@@ -57,6 +57,10 @@ We **DO NOT** use [SemVer](http://semver.org/) for versioning. Tho you can think
57
57
 
58
58
  See also the list of [contributors](https://github.com/kulshekhar/ts-jest/contributors) who participated in this project.
59
59
 
60
+ ## Supporters
61
+
62
+ - [JetBrains](https://www.jetbrains.com/?from=ts-jest) has been kind enough to support ts-jest with an [open source license](https://www.jetbrains.com/community/opensource/?from=ts-jest).
63
+
60
64
  ## License
61
65
 
62
66
  This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
@@ -11,10 +11,11 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
15
  return new (P || (P = Promise))(function (resolve, reject) {
15
16
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
17
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
19
  step((generator = generator.apply(thisArg, _arguments || [])).next());
19
20
  });
20
21
  };
@@ -45,13 +46,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
47
  }
47
48
  };
48
- var _this = this;
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  var fs_1 = require("fs");
51
51
  var json5_1 = require("json5");
52
52
  var path_1 = require("path");
53
53
  var presets_1 = require("../helpers/presets");
54
- exports.run = function (args) { return __awaiter(_this, void 0, void 0, function () {
54
+ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
55
55
  var file, filePath, name, isPackage, exists, pkgFile, hasPackage, _a, jestPreset, askedTsconfig, force, jsdom, tsconfig, pkgJson, jsFilesProcessor, shouldPostProcessWithBabel, preset, body, base, tsJestConf, content;
56
56
  return __generator(this, function (_b) {
57
57
  file = args._[0] || 'jest.config.js';
@@ -110,7 +110,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
110
110
  if (shouldPostProcessWithBabel)
111
111
  tsJestConf.babelConfig = true;
112
112
  }
113
- body = JSON.stringify(__assign({}, pkgJson, { jest: base }), undefined, ' ');
113
+ body = JSON.stringify(__assign(__assign({}, pkgJson), { jest: base }), undefined, ' ');
114
114
  }
115
115
  else {
116
116
  content = [];
@@ -144,7 +144,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
144
144
  return [2];
145
145
  });
146
146
  }); };
147
- exports.help = function () { return __awaiter(_this, void 0, void 0, function () {
147
+ exports.help = function () { return __awaiter(void 0, void 0, void 0, function () {
148
148
  return __generator(this, function (_a) {
149
149
  process.stdout.write("\nUsage:\n ts-jest config:init [options] [<config-file>]\n\nArguments:\n <config-file> Can be a js or json Jest config file. If it is a\n package.json file, the configuration will be read from\n the \"jest\" property.\n Default: jest.config.js\n\nOptions:\n --force Discard any existing Jest config\n --js ts|babel Process .js files with ts-jest if 'ts' or with\n babel-jest if 'babel'\n --no-jest-preset Disable the use of Jest presets\n --tsconfig <file> Path to the tsconfig.json file\n --babel Pipe babel-jest after ts-jest\n --jsdom Use jsdom as test environment instead of node\n");
150
150
  return [2];
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
4
5
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
6
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
@@ -54,19 +55,15 @@ var __spread = (this && this.__spread) || function () {
54
55
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
55
56
  return ar;
56
57
  };
57
- var __importDefault = (this && this.__importDefault) || function (mod) {
58
- return (mod && mod.__esModule) ? mod : { "default": mod };
59
- };
60
- var _this = this;
61
58
  Object.defineProperty(exports, "__esModule", { value: true });
62
59
  var bs_logger_1 = require("bs-logger");
63
- var fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
60
+ var stringifyJson = require("fast-json-stable-stringify");
64
61
  var fs_1 = require("fs");
65
62
  var json5_1 = require("json5");
66
63
  var path_1 = require("path");
67
64
  var backports_1 = require("../../util/backports");
68
65
  var presets_1 = require("../helpers/presets");
69
- exports.run = function (args) { return __awaiter(_this, void 0, void 0, function () {
66
+ exports.run = function (args) { return __awaiter(void 0, void 0, void 0, function () {
70
67
  var nullLogger, file, filePath, footNotes, name, isPackage, actualConfig, migratedConfig, presetName, preset, jsTransformers, jsWithTs, jsWithBabel, presetValue, migratedValue, presetValue, migratedValue, before, after, stringify, prefix;
71
68
  return __generator(this, function (_a) {
72
69
  nullLogger = bs_logger_1.createLogger({ targets: [] });
@@ -158,13 +155,13 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
158
155
  }
159
156
  if (preset &&
160
157
  migratedConfig.transform &&
161
- fast_json_stable_stringify_1.default(migratedConfig.transform) === fast_json_stable_stringify_1.default(preset.value.transform)) {
158
+ stringifyJson(migratedConfig.transform) === stringifyJson(preset.value.transform)) {
162
159
  delete migratedConfig.transform;
163
160
  }
164
161
  cleanupConfig(actualConfig);
165
162
  cleanupConfig(migratedConfig);
166
- before = fast_json_stable_stringify_1.default(actualConfig);
167
- after = fast_json_stable_stringify_1.default(migratedConfig);
163
+ before = stringifyJson(actualConfig);
164
+ after = stringifyJson(migratedConfig);
168
165
  if (after === before) {
169
166
  process.stderr.write("\nNo migration needed for given Jest configuration\n ");
170
167
  return [2];
@@ -212,7 +209,7 @@ function dedupSort(arr) {
212
209
  .filter(function (s, i, a) { return a.findIndex(function (e) { return s.toString() === e.toString(); }) === i; })
213
210
  .sort(function (a, b) { return (a.toString() > b.toString() ? 1 : a.toString() < b.toString() ? -1 : 0); });
214
211
  }
215
- exports.help = function () { return __awaiter(_this, void 0, void 0, function () {
212
+ exports.help = function () { return __awaiter(void 0, void 0, void 0, function () {
216
213
  return __generator(this, function (_a) {
217
214
  process.stdout.write("\nUsage:\n ts-jest config:migrate [options] <config-file>\n\nArguments:\n <config-file> Can be a js or json Jest config file. If it is a\n package.json file, the configuration will be read from\n the \"jest\" property.\n\nOptions:\n --js ts|babel Process .js files with ts-jest if 'ts' or with\n babel-jest if 'babel'\n --no-jest-preset Disable the use of Jest presets\n");
218
215
  return [2];
package/dist/cli/help.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
4
5
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
6
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
@@ -34,9 +35,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
36
  }
36
37
  };
37
- var _this = this;
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.run = function (_) { return __awaiter(_this, void 0, void 0, function () {
39
+ exports.run = function (_) { return __awaiter(void 0, void 0, void 0, function () {
40
40
  return __generator(this, function (_a) {
41
41
  process.stdout.write("\nUsage:\n ts-jest command [options] [...args]\n\nCommands:\n config:init Creates initial Jest configuration\n config:migrate Migrates a given Jest configuration\n help [command] Show this help, or help about a command\n\nExample:\n ts-jest help config:migrate\n");
42
42
  return [2];
package/dist/cli/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
4
5
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
6
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
@@ -34,13 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
36
  }
36
37
  };
37
- var __importDefault = (this && this.__importDefault) || function (mod) {
38
- return (mod && mod.__esModule) ? mod : { "default": mod };
39
- };
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
38
  var _a;
39
+ Object.defineProperty(exports, "__esModule", { value: true });
42
40
  var bs_logger_1 = require("bs-logger");
43
- var yargs_parser_1 = __importDefault(require("yargs-parser"));
41
+ var yargsParser = require("yargs-parser");
44
42
  var logger_1 = require("../util/logger");
45
43
  var VALID_COMMANDS = ['help', 'config:migrate', 'config:init'];
46
44
  var logger = logger_1.rootLogger.child((_a = {}, _a[bs_logger_1.LogContexts.namespace] = 'cli', _a[bs_logger_1.LogContexts.application] = 'ts-jest', _a));
@@ -48,7 +46,7 @@ function cli(args) {
48
46
  return __awaiter(this, void 0, void 0, function () {
49
47
  var parsedArgv, command, isHelp, _a, run, help, cmd;
50
48
  return __generator(this, function (_b) {
51
- parsedArgv = yargs_parser_1.default(args, {
49
+ parsedArgv = yargsParser(args, {
52
50
  boolean: ['dry-run', 'jest-preset', 'allow-js', 'diff', 'babel', 'force', 'jsdom'],
53
51
  string: ['tsconfig', 'js'],
54
52
  count: ['verbose'],
package/dist/compiler.js CHANGED
@@ -10,15 +10,16 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __values = (this && this.__values) || function (o) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
13
+ var __values = (this && this.__values) || function(o) {
14
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
15
15
  if (m) return m.call(o);
16
- return {
16
+ if (o && typeof o.length === "number") return {
17
17
  next: function () {
18
18
  if (o && i >= o.length) o = void 0;
19
19
  return { value: o && o[i++], done: !o };
20
20
  }
21
21
  };
22
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
23
  };
23
24
  var __read = (this && this.__read) || function (o, n) {
24
25
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -36,14 +37,12 @@ var __read = (this && this.__read) || function (o, n) {
36
37
  }
37
38
  return ar;
38
39
  };
39
- var __importDefault = (this && this.__importDefault) || function (mod) {
40
- return (mod && mod.__esModule) ? mod : { "default": mod };
41
- };
42
40
  Object.defineProperty(exports, "__esModule", { value: true });
43
41
  var bs_logger_1 = require("bs-logger");
44
- var buffer_from_1 = __importDefault(require("buffer-from"));
42
+ var bufferFrom = require("buffer-from");
45
43
  var stableStringify = require("fast-json-stable-stringify");
46
44
  var fs_1 = require("fs");
45
+ var memoize = require("lodash.memoize");
47
46
  var mkdirp = require("mkdirp");
48
47
  var path_1 = require("path");
49
48
  var messages_1 = require("./util/messages");
@@ -112,30 +111,33 @@ function createCompiler(configs) {
112
111
  _b.namespace = 'ts:serviceHost',
113
112
  _b.call = null,
114
113
  _b);
115
- var serviceHostTraceCtx = __assign({}, serviceHostDebugCtx, (_c = {}, _c[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.trace, _c));
114
+ var serviceHostTraceCtx = __assign(__assign({}, serviceHostDebugCtx), (_c = {}, _c[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.trace, _c));
116
115
  var serviceHost = {
117
116
  getScriptFileNames: function () { return Object.keys(memoryCache.versions); },
118
117
  getScriptVersion: function (fileName) {
119
- var version = memoryCache.versions[fileName];
118
+ var normalizedFileName = path_1.normalize(fileName);
119
+ var version = memoryCache.versions[normalizedFileName];
120
120
  return version === undefined ? undefined : String(version);
121
121
  },
122
122
  getScriptSnapshot: function (fileName) {
123
- var hit = hasOwn.call(memoryCache.contents, fileName);
124
- logger.trace({ fileName: fileName, cacheHit: hit }, "getScriptSnapshot():", 'cache', hit ? 'hit' : 'miss');
123
+ var normalizedFileName = path_1.normalize(fileName);
124
+ var hit = hasOwn.call(memoryCache.contents, normalizedFileName);
125
+ logger.trace({ normalizedFileName: normalizedFileName, cacheHit: hit }, "getScriptSnapshot():", 'cache', hit ? 'hit' : 'miss');
125
126
  if (!hit) {
126
- memoryCache.contents[fileName] = ts.sys.readFile(fileName);
127
+ memoryCache.contents[normalizedFileName] = ts.sys.readFile(normalizedFileName);
127
128
  }
128
- var contents = memoryCache.contents[fileName];
129
+ var contents = memoryCache.contents[normalizedFileName];
129
130
  if (contents === undefined) {
130
131
  return;
131
132
  }
132
133
  return ts.ScriptSnapshot.fromString(contents);
133
134
  },
134
- fileExists: ts.sys.fileExists,
135
- readFile: logger.wrap(serviceHostTraceCtx, 'readFile', ts.sys.readFile),
136
- readDirectory: ts.sys.readDirectory,
137
- getDirectories: ts.sys.getDirectories,
138
- directoryExists: ts.sys.directoryExists,
135
+ fileExists: memoize(ts.sys.fileExists),
136
+ readFile: logger.wrap(serviceHostTraceCtx, 'readFile', memoize(ts.sys.readFile)),
137
+ readDirectory: memoize(ts.sys.readDirectory),
138
+ getDirectories: memoize(ts.sys.getDirectories),
139
+ directoryExists: memoize(ts.sys.directoryExists),
140
+ realpath: memoize(ts.sys.realpath),
139
141
  getNewLine: function () { return '\n'; },
140
142
  getCurrentDirectory: function () { return cwd; },
141
143
  getCompilationSettings: function () { return compilerOptions; },
@@ -213,7 +215,7 @@ function readThrough(cachedir, memoryCache, compile, getExtension, cwd, logger)
213
215
  }
214
216
  function updateOutput(outputText, fileName, sourceMap, getExtension, sourceRoot) {
215
217
  var base = path_1.basename(fileName);
216
- var base64Map = buffer_from_1.default(updateSourceMap(sourceMap, fileName, sourceRoot), 'utf8').toString('base64');
218
+ var base64Map = bufferFrom(updateSourceMap(sourceMap, fileName, sourceRoot), 'utf8').toString('base64');
217
219
  var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
218
220
  var sourceMapLength = (base + ".map").length + (getExtension(fileName).length - path_1.extname(fileName).length);
219
221
  return outputText.slice(0, -sourceMapLength) + sourceMapContent;
@@ -226,7 +228,7 @@ function updateSourceMap(sourceMapText, fileName, _sourceRoot) {
226
228
  return stableStringify(sourceMap);
227
229
  }
228
230
  function getCacheName(sourceCode, fileName) {
229
- return sha1_1.sha1(path_1.extname(fileName), '\x00', sourceCode);
231
+ return sha1_1.sha1(fileName, '\x00', sourceCode);
230
232
  }
231
233
  function isValidCacheContent(contents) {
232
234
  return /(?:9|0=|Q==)$/.test(contents.slice(-3));
@@ -4,29 +4,29 @@ import { CompilerOptions, CustomTransformers, ParsedCommandLine } from 'typescri
4
4
  import { AstTransformerDesc, BabelConfig, BabelJestTransformer, TTypeScript, TsCompiler, TsJestConfig, TsJestGlobalOptions, TsJestHooksMap } from '../types';
5
5
  export declare class ConfigSet {
6
6
  readonly parentOptions?: TsJestGlobalOptions | undefined;
7
- readonly projectPackageJson: Record<string, any>;
8
- readonly projectDependencies: Record<string, string>;
9
- readonly jest: jest.ProjectConfig;
10
- readonly tsJest: TsJestConfig;
11
- readonly typescript: ParsedCommandLine;
12
- readonly tsconfig: any;
13
- readonly versions: Record<string, string>;
7
+ get projectPackageJson(): Record<string, any>;
8
+ get projectDependencies(): Record<string, string>;
9
+ get jest(): jest.ProjectConfig;
10
+ get tsJest(): TsJestConfig;
11
+ get typescript(): ParsedCommandLine;
12
+ get tsconfig(): any;
13
+ get versions(): Record<string, string>;
14
14
  private static loadConfig;
15
- readonly babel: BabelConfig | undefined;
16
- readonly compilerModule: TTypeScript;
17
- readonly babelJestTransformer: BabelJestTransformer | undefined;
18
- readonly tsCompiler: TsCompiler;
19
- readonly astTransformers: AstTransformerDesc[];
20
- readonly tsCustomTransformers: CustomTransformers;
21
- readonly hooks: TsJestHooksMap;
22
- readonly shouldReportDiagnostic: (filePath: string) => boolean;
23
- readonly shouldStringifyContent: (filePath: string) => boolean;
24
- readonly tsCacheDir: string | undefined;
25
- readonly overriddenCompilerOptions: Partial<CompilerOptions>;
26
- readonly rootDir: string;
27
- readonly cwd: string;
28
- readonly tsJestDigest: string;
29
- readonly cacheKey: string;
15
+ get babel(): BabelConfig | undefined;
16
+ get compilerModule(): TTypeScript;
17
+ get babelJestTransformer(): BabelJestTransformer | undefined;
18
+ get tsCompiler(): TsCompiler;
19
+ get astTransformers(): AstTransformerDesc[];
20
+ get tsCustomTransformers(): CustomTransformers;
21
+ get hooks(): TsJestHooksMap;
22
+ get shouldReportDiagnostic(): (filePath: string) => boolean;
23
+ get shouldStringifyContent(): (filePath: string) => boolean;
24
+ get tsCacheDir(): string | undefined;
25
+ get overriddenCompilerOptions(): Partial<CompilerOptions>;
26
+ get rootDir(): string;
27
+ get cwd(): string;
28
+ get tsJestDigest(): string;
29
+ get cacheKey(): string;
30
30
  readonly logger: Logger;
31
31
  constructor(jestConfig: jest.ProjectConfig, parentOptions?: TsJestGlobalOptions | undefined, parentLogger?: Logger);
32
32
  resolvePath(inputPath: string, { throwIfMissing, nodeResolve }?: {
@@ -16,15 +16,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
16
16
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
17
  return c > 3 && r && Object.defineProperty(target, key, r), r;
18
18
  };
19
- var __values = (this && this.__values) || function (o) {
20
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
19
+ var __values = (this && this.__values) || function(o) {
20
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21
21
  if (m) return m.call(o);
22
- return {
22
+ if (o && typeof o.length === "number") return {
23
23
  next: function () {
24
24
  if (o && i >= o.length) o = void 0;
25
25
  return { value: o && o[i++], done: !o };
26
26
  }
27
27
  };
28
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
28
29
  };
29
30
  var __read = (this && this.__read) || function (o, n) {
30
31
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -46,15 +47,12 @@ var __spread = (this && this.__spread) || function () {
46
47
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
47
48
  return ar;
48
49
  };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
50
  Object.defineProperty(exports, "__esModule", { value: true });
53
51
  var bs_logger_1 = require("bs-logger");
54
52
  var fs_1 = require("fs");
55
- var json5_1 = __importDefault(require("json5"));
53
+ var json5 = require("json5");
56
54
  var path_1 = require("path");
57
- var semver_1 = __importDefault(require("semver"));
55
+ var semver = require("semver");
58
56
  var __1 = require("..");
59
57
  var compiler_1 = require("../compiler");
60
58
  var transformers_1 = require("../transformers");
@@ -88,8 +86,8 @@ var toDiagnosticCode = function (code) {
88
86
  return code ? parseInt(("" + code).trim().replace(/^TS/, ''), 10) || undefined : undefined;
89
87
  };
90
88
  var toDiagnosticCodeList = function (items, into) {
91
- if (into === void 0) { into = []; }
92
89
  var e_1, _a;
90
+ if (into === void 0) { into = []; }
93
91
  if (!Array.isArray(items))
94
92
  items = [items];
95
93
  try {
@@ -166,7 +164,7 @@ var ConfigSet = (function () {
166
164
  Object.defineProperty(ConfigSet.prototype, "projectDependencies", {
167
165
  get: function () {
168
166
  var pkg = this.projectPackageJson;
169
- var names = Object.keys(__assign({}, pkg.optionalDependencies, pkg.peerDependencies, pkg.devDependencies, pkg.dependencies));
167
+ var names = Object.keys(__assign(__assign(__assign(__assign({}, pkg.optionalDependencies), pkg.peerDependencies), pkg.devDependencies), pkg.dependencies));
170
168
  return names.reduce(function (map, name) {
171
169
  var version = get_package_version_1.getPackageVersion(name);
172
170
  if (version)
@@ -182,7 +180,7 @@ var ConfigSet = (function () {
182
180
  var config = backports_1.backportJestConfig(this.logger, this._jestConfig);
183
181
  if (this.parentOptions) {
184
182
  var globals = config.globals || (config.globals = {});
185
- globals['ts-jest'] = __assign({}, this.parentOptions, globals['ts-jest']);
183
+ globals['ts-jest'] = __assign(__assign({}, this.parentOptions), globals['ts-jest']);
186
184
  }
187
185
  this.logger.debug({ jestConfig: config }, 'normalized jest config');
188
186
  return config;
@@ -342,7 +340,7 @@ var ConfigSet = (function () {
342
340
  });
343
341
  ConfigSet.loadConfig = function (base) {
344
342
  var _a = importer_1.importer.babelCore(messages_1.ImportReasons.BabelJest), OptionManager = _a.OptionManager, loadPartialConfig = _a.loadPartialConfig, version = _a.version;
345
- if (version && semver_1.default.satisfies(version, '>=6 <7')) {
343
+ if (version && semver.satisfies(version, '>=6 <7')) {
346
344
  delete base.cwd;
347
345
  }
348
346
  if (typeof loadPartialConfig === 'function') {
@@ -363,11 +361,16 @@ var ConfigSet = (function () {
363
361
  var base = { cwd: this.cwd };
364
362
  if (babelConfig.kind === 'file') {
365
363
  if (babelConfig.value) {
366
- base = __assign({}, base, json5_1.default.parse(fs_1.readFileSync(babelConfig.value, 'utf8')));
364
+ if (path_1.extname(babelConfig.value) === '.js') {
365
+ base = __assign(__assign({}, base), require(babelConfig.value));
366
+ }
367
+ else {
368
+ base = __assign(__assign({}, base), json5.parse(fs_1.readFileSync(babelConfig.value, 'utf8')));
369
+ }
367
370
  }
368
371
  }
369
372
  else if (babelConfig.kind === 'inline') {
370
- base = __assign({}, base, babelConfig.value);
373
+ base = __assign(__assign({}, base), babelConfig.value);
371
374
  }
372
375
  var config = ConfigSet.loadConfig(base);
373
376
  this.logger.debug({ babelConfig: config }, 'normalized babel config');
@@ -534,7 +537,9 @@ var ConfigSet = (function () {
534
537
  declarationDir: undefined,
535
538
  declarationMap: undefined,
536
539
  emitDeclarationOnly: undefined,
540
+ incremental: undefined,
537
541
  sourceRoot: undefined,
542
+ tsBuildInfoFile: undefined,
538
543
  };
539
544
  if (!this.tsJest.babelConfig) {
540
545
  options.module = this.compilerModule.ModuleKind.CommonJS;
@@ -635,11 +640,11 @@ var ConfigSet = (function () {
635
640
  };
636
641
  }
637
642
  config = result_1.config;
638
- input = __assign({}, result_1.config, { compilerOptions: __assign({}, (result_1.config && result_1.config.compilerOptions), compilerOptions) });
643
+ input = __assign(__assign({}, result_1.config), { compilerOptions: __assign(__assign({}, (result_1.config && result_1.config.compilerOptions)), compilerOptions) });
639
644
  basePath = normalize_slashes_1.normalizeSlashes(path_1.dirname(configFileName));
640
645
  }
641
646
  }
642
- config.compilerOptions = __assign({}, config.compilerOptions, compilerOptions);
647
+ config.compilerOptions = __assign(__assign({}, config.compilerOptions), compilerOptions);
643
648
  var result = ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, configFileName);
644
649
  var forcedOptions = this.overriddenCompilerOptions;
645
650
  var finalOptions = result.options;
@@ -14,10 +14,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  var logger_1 = require("../util/logger");
15
15
  var logger = logger_1.rootLogger.child({ namespace: 'jest-preset' });
16
16
  function createJestPreset(_a, from) {
17
- var _b = (_a === void 0 ? {} : _a).allowJs, allowJs = _b === void 0 ? false : _b;
17
+ var _b;
18
+ var _c = (_a === void 0 ? {} : _a).allowJs, allowJs = _c === void 0 ? false : _c;
18
19
  if (from === void 0) { from = {}; }
19
- var _c;
20
20
  logger.debug({ allowJs: allowJs }, 'creating jest presets', allowJs ? 'handling' : 'not handling', 'JavaScript files');
21
- return __assign({ transform: __assign({}, from.transform, (_c = {}, _c[allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$'] = 'ts-jest', _c)) }, (from.testMatch ? { testMatch: from.testMatch } : undefined), (from.moduleFileExtensions ? { moduleFileExtensions: from.moduleFileExtensions } : undefined));
21
+ return __assign(__assign({ transform: __assign(__assign({}, from.transform), (_b = {}, _b[allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$'] = 'ts-jest', _b)) }, (from.testMatch ? { testMatch: from.testMatch } : undefined)), (from.moduleFileExtensions ? { moduleFileExtensions: from.moduleFileExtensions } : undefined));
22
22
  }
23
23
  exports.createJestPreset = createJestPreset;
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
- var __values = (this && this.__values) || function (o) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
4
  if (m) return m.call(o);
5
- return {
5
+ if (o && typeof o.length === "number") return {
6
6
  next: function () {
7
7
  if (o && i >= o.length) o = void 0;
8
8
  return { value: o && o[i++], done: !o };
9
9
  }
10
10
  };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
12
  };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
13
  var _a;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
14
15
  var bs_logger_1 = require("bs-logger");
15
16
  var logger_1 = require("../util/logger");
16
17
  var messages_1 = require("../util/messages");
17
18
  var escapeRegex = function (str) { return str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'); };
18
19
  var logger = logger_1.rootLogger.child((_a = {}, _a[bs_logger_1.LogContexts.namespace] = 'path-mapper', _a));
19
20
  exports.pathsToModuleNameMapper = function (mapping, _a) {
20
- var _b = (_a === void 0 ? {} : _a).prefix, prefix = _b === void 0 ? '' : _b;
21
- var e_1, _c;
21
+ var e_1, _b;
22
+ var _c = (_a === void 0 ? {} : _a).prefix, prefix = _c === void 0 ? '' : _c;
22
23
  var jestMap = {};
23
24
  try {
24
25
  for (var _d = __values(Object.keys(mapping)), _e = _d.next(); !_e.done; _e = _d.next()) {
@@ -54,7 +55,7 @@ exports.pathsToModuleNameMapper = function (mapping, _a) {
54
55
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
55
56
  finally {
56
57
  try {
57
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
58
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
58
59
  }
59
60
  finally { if (e_1) throw e_1.error; }
60
61
  }
package/dist/index.js CHANGED
@@ -19,8 +19,8 @@ var __spread = (this && this.__spread) || function () {
19
19
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
20
  return ar;
21
21
  };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
22
  var _a;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  var bs_logger_1 = require("bs-logger");
25
25
  var fs_1 = require("fs");
26
26
  var path_1 = require("path");
@@ -50,20 +50,20 @@ function createTransformer(baseConfig) {
50
50
  }
51
51
  exports.createTransformer = createTransformer;
52
52
  function process() {
53
+ var _a;
53
54
  var args = [];
54
55
  for (var _i = 0; _i < arguments.length; _i++) {
55
56
  args[_i] = arguments[_i];
56
57
  }
57
- var _a;
58
58
  return (_a = defaultTransformer()).process.apply(_a, __spread(args));
59
59
  }
60
60
  exports.process = process;
61
61
  function getCacheKey() {
62
+ var _a;
62
63
  var args = [];
63
64
  for (var _i = 0; _i < arguments.length; _i++) {
64
65
  args[_i] = arguments[_i];
65
66
  }
66
- var _a;
67
67
  return (_a = defaultTransformer()).getCacheKey.apply(_a, __spread(args));
68
68
  }
69
69
  exports.getCacheKey = getCacheKey;
@@ -21,7 +21,7 @@ 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'];
24
+ var HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock'];
25
25
  exports.name = 'hoisting-jest-mock';
26
26
  exports.version = 1;
27
27
  function factory(cs) {
@@ -1,11 +1,4 @@
1
1
  "use strict";
2
- var __importStar = (this && this.__importStar) || function (mod) {
3
- if (mod && mod.__esModule) return mod;
4
- var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
7
- return result;
8
- };
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
- var hoisting = __importStar(require("./hoist-jest"));
3
+ var hoisting = require("./hoist-jest");
11
4
  exports.internals = [hoisting];
@@ -3,7 +3,7 @@ import { Logger } from 'bs-logger';
3
3
  import { ConfigSet } from './config/config-set';
4
4
  import { TsJestGlobalOptions } from './types';
5
5
  export declare class TsJestTransformer implements jest.Transformer {
6
- static readonly lastTransformerId: number;
6
+ static get lastTransformerId(): number;
7
7
  readonly logger: Logger;
8
8
  readonly id: number;
9
9
  readonly options: TsJestGlobalOptions;
@@ -107,7 +107,7 @@ var TsJestTransformer = (function () {
107
107
  }
108
108
  if (babelJest) {
109
109
  this.logger.debug({ fileName: filePath }, 'calling babel-jest processor');
110
- result = babelJest.process(result, filePath, jestConfig, __assign({}, transformOptions, { instrument: false }));
110
+ result = babelJest.process(result, filePath, jestConfig, __assign(__assign({}, transformOptions), { instrument: false }));
111
111
  }
112
112
  if (hooks.afterProcess) {
113
113
  this.logger.debug({ fileName: filePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /// <reference types="jest" />
2
2
  import * as _babel from 'babel__core';
3
- import _ts, { CompilerOptions, SourceFile, TransformerFactory } from 'typescript';
3
+ import { CompilerOptions, SourceFile, TransformerFactory } from 'typescript';
4
+ import * as _ts from 'typescript';
4
5
  import { ConfigSet } from './config/config-set';
5
6
  export declare type TBabelCore = typeof _babel;
6
7
  export declare type TTypeScript = typeof _ts;
@@ -10,13 +10,13 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
13
  var _a;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  var bs_logger_1 = require("bs-logger");
16
16
  var messages_1 = require("./messages");
17
17
  var context = (_a = {}, _a[bs_logger_1.LogContexts.namespace] = 'backports', _a);
18
18
  exports.backportJestConfig = function (logger, config) {
19
- logger.debug(__assign({}, context, { config: config }), 'backporting config');
19
+ logger.debug(__assign(__assign({}, context), { config: config }), 'backporting config');
20
20
  var _a = (config || {}).globals, globals = _a === void 0 ? {} : _a;
21
21
  var _b = globals["ts-jest"], tsJest = _b === void 0 ? {} : _b;
22
22
  var mergeTsJest = {};
@@ -84,7 +84,7 @@ exports.backportJestConfig = function (logger, config) {
84
84
  if (hadWarnings) {
85
85
  logger.warn(context, messages_1.Helps.MigrateConfigUsingCLI);
86
86
  }
87
- return __assign({}, config, { globals: __assign({}, globals, { 'ts-jest': __assign({}, mergeTsJest, tsJest) }) });
87
+ return __assign(__assign({}, config), { globals: __assign(__assign({}, globals), { 'ts-jest': __assign(__assign({}, mergeTsJest), tsJest) }) });
88
88
  };
89
89
  exports.backportTsJestDebugEnvVar = function (logger) {
90
90
  if ('TS_JEST_DEBUG' in process.env) {
@@ -1,35 +1,34 @@
1
1
  /// <reference types="jest" />
2
- interface MockWithArgs<T> extends Function, jest.MockInstance<T> {
3
- new (...args: ArgumentsOf<T>): T;
4
- (...args: ArgumentsOf<T>): any;
5
- }
2
+ declare type MockableFunction = (...args: any[]) => any;
6
3
  declare type MethodKeysOf<T> = {
7
- [K in keyof T]: T[K] extends Function ? K : never;
4
+ [K in keyof T]: T[K] extends MockableFunction ? K : never;
8
5
  }[keyof T];
9
6
  declare type PropertyKeysOf<T> = {
10
- [K in keyof T]: T[K] extends Function ? never : K;
7
+ [K in keyof T]: T[K] extends MockableFunction ? never : K;
11
8
  }[keyof T];
12
9
  declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
13
- interface MockWithArgs<T> extends Function, jest.MockInstance<T> {
14
- new (...args: ArgumentsOf<T>): T;
15
- (...args: ArgumentsOf<T>): any;
10
+ declare type ConstructorArgumentsOf<T> = T extends new (...args: infer A) => any ? A : never;
11
+ interface MockWithArgs<T extends MockableFunction> extends jest.MockInstance<ReturnType<T>, ArgumentsOf<T>> {
12
+ new (...args: ConstructorArgumentsOf<T>): T;
13
+ (...args: ArgumentsOf<T>): ReturnType<T>;
16
14
  }
17
- declare type MockedFunction<T> = MockWithArgs<T> & {
15
+ declare type MaybeMockedConstructor<T> = T extends new (...args: any[]) => infer R ? jest.MockInstance<R, ConstructorArgumentsOf<T>> : {};
16
+ declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
18
17
  [K in keyof T]: T[K];
19
18
  };
20
- declare type MockedFunctionDeep<T> = MockWithArgs<T> & MockedObjectDeep<T>;
21
- declare type MockedObject<T> = {
22
- [K in MethodKeysOf<T>]: MockedFunction<T[K]>;
19
+ declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
20
+ declare type MockedObject<T> = MaybeMockedConstructor<T> & {
21
+ [K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunction<T[K]> : T[K];
23
22
  } & {
24
23
  [K in PropertyKeysOf<T>]: T[K];
25
24
  };
26
- declare type MockedObjectDeep<T> = {
27
- [K in MethodKeysOf<T>]: MockedFunctionDeep<T[K]>;
25
+ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
26
+ [K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunctionDeep<T[K]> : T[K];
28
27
  } & {
29
28
  [K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]>;
30
29
  };
31
- export declare type MaybeMockedDeep<T> = T extends Function ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
32
- export declare type MaybeMocked<T> = T extends Function ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
30
+ export declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
31
+ export declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
33
32
  export declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
34
33
  export declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
35
34
  export {};
@@ -5,7 +5,7 @@ var __extends = (this && this.__extends) || (function () {
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
6
  function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
- }
8
+ };
9
9
  return function (d, b) {
10
10
  extendStatics(d, b);
11
11
  function __() { this.constructor = d; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "24.0.1",
3
+ "version": "24.3.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": "cli.js",
@@ -33,6 +33,7 @@
33
33
  "prepare": "npm run build",
34
34
  "prepublishOnly": "npm run test",
35
35
  "preversion": "npm run test",
36
+ "update:e2e": "node scripts/update-e2e-templates.js",
36
37
  "version": "npm run changelog && git add CHANGELOG.md"
37
38
  },
38
39
  "repository": {
@@ -59,6 +60,7 @@
59
60
  "bs-logger": "0.x",
60
61
  "buffer-from": "1.x",
61
62
  "fast-json-stable-stringify": "2.x",
63
+ "lodash.memoize": "4.x",
62
64
  "json5": "2.x",
63
65
  "make-error": "1.x",
64
66
  "mkdirp": "0.x",
@@ -77,7 +79,7 @@
77
79
  }
78
80
  },
79
81
  "devDependencies": {
80
- "@commitlint/cli": "7.x",
82
+ "@commitlint/cli": "8.x",
81
83
  "@commitlint/config-conventional": "7.x",
82
84
  "@types/babel__core": "7.x",
83
85
  "@types/buffer-from": "latest",
@@ -103,7 +105,6 @@
103
105
  "jest": "24.x",
104
106
  "js-yaml": "latest",
105
107
  "lint-staged": "latest",
106
- "lodash.memoize": "4.x",
107
108
  "lodash.merge": "4.x",
108
109
  "lodash.set": "4.x",
109
110
  "npm-run-all": "latest",
@@ -115,16 +116,14 @@
115
116
  "typescript": "3.x"
116
117
  },
117
118
  "lint-staged": {
118
- "linters": {
119
- "*.{ts,tsx}": [
120
- "tslint --fix",
121
- "git add"
122
- ],
123
- "*.{js,jsx}": [
124
- "eslint --fix",
125
- "git add"
126
- ]
127
- }
119
+ "*.{ts,tsx}": [
120
+ "tslint --fix",
121
+ "git add"
122
+ ],
123
+ "*.{js,jsx}": [
124
+ "eslint --fix",
125
+ "git add"
126
+ ]
128
127
  },
129
128
  "engines": {
130
129
  "node": ">= 6"
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- package-lock.json -diff -merge
2
- package-lock.json linguist-generated=true
package/icon.png DELETED
Binary file