ts-jest 23.10.5 → 24.1.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
- 3fe12324700b93d3377a5957ccfc2f339524ce17
1
+ 7145adc485d1d0fa5bc7b6467bd416798f0a9a49
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
- <a name="23.10.5"></a>
2
- ## [23.10.5](https://github.com/kulshekhar/ts-jest/compare/v23.10.4...v23.10.5) (2018-11-22)
1
+ <a name="24.1.0"></a>
2
+ # [24.1.0](https://github.com/kulshekhar/ts-jest/compare/v24.0.2...v24.1.0) (2019-09-12)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * [#825](https://github.com/kulshekhar/ts-jest/issues/825) handle symlinked modules (ala pnpm) correctly ([e190b23](https://github.com/kulshekhar/ts-jest/commit/e190b23))
8
+ * handle tsBuildInfoFile option ([f9583e9](https://github.com/kulshekhar/ts-jest/commit/f9583e9)), closes [#1095](https://github.com/kulshekhar/ts-jest/issues/1095)
9
+ * **perf:** add cache for fs calls ([#908](https://github.com/kulshekhar/ts-jest/issues/908)) ([3dada81](https://github.com/kulshekhar/ts-jest/commit/3dada81))
10
+ * **types:** unforce esModuleInterop in tsconfig.json ([c2d39b6](https://github.com/kulshekhar/ts-jest/commit/c2d39b6))
11
+
12
+
13
+
14
+ <a name="24.0.2"></a>
15
+ ## [24.0.2](https://github.com/kulshekhar/ts-jest/compare/v24.0.1...v24.0.2) (2019-04-05)
16
+
17
+
18
+
19
+ <a name="24.0.1"></a>
20
+ ## [24.0.1](https://github.com/kulshekhar/ts-jest/compare/v24.0.0...v24.0.1) (2019-03-30)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * update call to globIgnore ([#1002](https://github.com/kulshekhar/ts-jest/issues/1002)) ([#1003](https://github.com/kulshekhar/ts-jest/issues/1003)) ([05b63af](https://github.com/kulshekhar/ts-jest/commit/05b63af))
26
+
27
+
28
+ ### Features
29
+
30
+ * **config:** specify package.json location ([#823](https://github.com/kulshekhar/ts-jest/issues/823)) ([#1013](https://github.com/kulshekhar/ts-jest/issues/1013)) ([fb7dd55](https://github.com/kulshekhar/ts-jest/commit/fb7dd55))
31
+
32
+
33
+
34
+ <a name="24.0.0"></a>
35
+ # [24.0.0](https://github.com/kulshekhar/ts-jest/compare/v23.10.5...v24.0.0) (2019-02-18)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * cli test ([1d67101](https://github.com/kulshekhar/ts-jest/commit/1d67101))
41
+ * module tests and some snapshots ([999f889](https://github.com/kulshekhar/ts-jest/commit/999f889))
42
+ * remove unused snapshots ([108b08b](https://github.com/kulshekhar/ts-jest/commit/108b08b))
43
+ * some tests ([d0f2231](https://github.com/kulshekhar/ts-jest/commit/d0f2231))
44
+ * test command ([8372b5e](https://github.com/kulshekhar/ts-jest/commit/8372b5e))
45
+ * test path for windows (attempt 1) ([6824ac4](https://github.com/kulshekhar/ts-jest/commit/6824ac4))
46
+ * test path for windows (attempt 2) ([eb2fc8a](https://github.com/kulshekhar/ts-jest/commit/eb2fc8a))
47
+
48
+
49
+ ### Features
50
+
51
+ * **jest:** bump to 24 ([defcb77](https://github.com/kulshekhar/ts-jest/commit/defcb77))
3
52
 
4
53
 
5
54
 
package/README.md CHANGED
@@ -31,8 +31,8 @@ These instructions will get you setup to use `ts-jest` in your project. For more
31
31
  |---:|---|---|
32
32
  | **Prerequisites** | `npm i -D jest typescript` | `yarn add --dev jest typescript` |
33
33
  | **Installing** | `npm i -D ts-jest @types/jest` | `yarn add --dev ts-jest @types/jest` |
34
- | **Creating config** | `node_modules/.bin/ts-jest config:init` | `yarn ts-jest config:init` |
35
- | **Running tests** | `npm t` or `node_modules/.bin/jest` | `yarn test` or `yarn jest` |
34
+ | **Creating config** | `npx ts-jest config:init` | `yarn ts-jest config:init` |
35
+ | **Running tests** | `npm t` or `npx jest` | `yarn test` or `yarn jest` |
36
36
 
37
37
  ## Built With
38
38
 
@@ -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 follow 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
 
@@ -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: [] });
@@ -131,7 +128,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
131
128
  if (preset)
132
129
  migratedConfig.preset = preset.name;
133
130
  if (migratedConfig.moduleFileExtensions && migratedConfig.moduleFileExtensions.length && preset) {
134
- presetValue = dedupSort(preset.value.moduleFileExtensions).join('::');
131
+ presetValue = dedupSort(preset.value.moduleFileExtensions || []).join('::');
135
132
  migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::');
136
133
  if (presetValue === migratedValue) {
137
134
  delete migratedConfig.moduleFileExtensions;
@@ -141,7 +138,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
141
138
  migratedConfig.testMatch = null;
142
139
  }
143
140
  else if (migratedConfig.testMatch && migratedConfig.testMatch.length && preset) {
144
- presetValue = dedupSort(preset.value.testMatch).join('::');
141
+ presetValue = dedupSort(preset.value.testMatch || []).join('::');
145
142
  migratedValue = dedupSort(migratedConfig.testMatch).join('::');
146
143
  if (presetValue === migratedValue) {
147
144
  delete migratedConfig.testMatch;
@@ -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,7 +111,7 @@ 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) {
@@ -131,11 +130,12 @@ function createCompiler(configs) {
131
130
  }
132
131
  return ts.ScriptSnapshot.fromString(contents);
133
132
  },
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,
133
+ fileExists: memoize(ts.sys.fileExists),
134
+ readFile: logger.wrap(serviceHostTraceCtx, 'readFile', memoize(ts.sys.readFile)),
135
+ readDirectory: memoize(ts.sys.readDirectory),
136
+ getDirectories: memoize(ts.sys.getDirectories),
137
+ directoryExists: memoize(ts.sys.directoryExists),
138
+ realpath: memoize(ts.sys.realpath),
139
139
  getNewLine: function () { return '\n'; },
140
140
  getCurrentDirectory: function () { return cwd; },
141
141
  getCompilationSettings: function () { return compilerOptions; },
@@ -213,7 +213,7 @@ function readThrough(cachedir, memoryCache, compile, getExtension, cwd, logger)
213
213
  }
214
214
  function updateOutput(outputText, fileName, sourceMap, getExtension, sourceRoot) {
215
215
  var base = path_1.basename(fileName);
216
- var base64Map = buffer_from_1.default(updateSourceMap(sourceMap, fileName, sourceRoot), 'utf8').toString('base64');
216
+ var base64Map = bufferFrom(updateSourceMap(sourceMap, fileName, sourceRoot), 'utf8').toString('base64');
217
217
  var sourceMapContent = "data:application/json;charset=utf-8;base64," + base64Map;
218
218
  var sourceMapLength = (base + ".map").length + (getExtension(fileName).length - path_1.extname(fileName).length);
219
219
  return outputText.slice(0, -sourceMapLength) + sourceMapContent;
@@ -11,6 +11,7 @@ export declare class ConfigSet {
11
11
  readonly typescript: ParsedCommandLine;
12
12
  readonly tsconfig: any;
13
13
  readonly versions: Record<string, string>;
14
+ private static loadConfig;
14
15
  readonly babel: BabelConfig | undefined;
15
16
  readonly compilerModule: TTypeScript;
16
17
  readonly babelJestTransformer: BabelJestTransformer | undefined;
@@ -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 {
@@ -134,19 +132,31 @@ var ConfigSet = (function () {
134
132
  }
135
133
  Object.defineProperty(ConfigSet.prototype, "projectPackageJson", {
136
134
  get: function () {
135
+ var packageJson = this.tsJest.packageJson;
136
+ if (packageJson && packageJson.kind === 'inline') {
137
+ return packageJson.value;
138
+ }
139
+ if (packageJson && packageJson.kind === 'file' && packageJson.value) {
140
+ var path = this.resolvePath(packageJson.value);
141
+ if (fs_1.existsSync(path)) {
142
+ return require(path);
143
+ }
144
+ this.logger.warn(messages_1.Errors.UnableToFindProjectRoot);
145
+ return {};
146
+ }
137
147
  var tsJestRoot = path_1.resolve(__dirname, '..', '..');
138
148
  var pkgPath = path_1.resolve(tsJestRoot, '..', '..', 'package.json');
139
- var exists = fs_1.existsSync(pkgPath);
140
- if (!exists) {
141
- if (fs_1.realpathSync(this.rootDir) === fs_1.realpathSync(tsJestRoot)) {
142
- pkgPath = path_1.resolve(tsJestRoot, 'package.json');
143
- exists = true;
144
- }
145
- else {
146
- this.logger.warn(messages_1.Errors.UnableToFindProjectRoot);
149
+ if (fs_1.existsSync(pkgPath)) {
150
+ return require(pkgPath);
151
+ }
152
+ if (fs_1.realpathSync(this.rootDir) === fs_1.realpathSync(tsJestRoot)) {
153
+ pkgPath = path_1.resolve(tsJestRoot, 'package.json');
154
+ if (fs_1.existsSync(pkgPath)) {
155
+ return require(pkgPath);
147
156
  }
148
157
  }
149
- return exists ? require(pkgPath) : {};
158
+ this.logger.warn(messages_1.Errors.UnableToFindProjectRoot);
159
+ return {};
150
160
  },
151
161
  enumerable: true,
152
162
  configurable: true
@@ -154,7 +164,7 @@ var ConfigSet = (function () {
154
164
  Object.defineProperty(ConfigSet.prototype, "projectDependencies", {
155
165
  get: function () {
156
166
  var pkg = this.projectPackageJson;
157
- 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));
158
168
  return names.reduce(function (map, name) {
159
169
  var version = get_package_version_1.getPackageVersion(name);
160
170
  if (version)
@@ -170,7 +180,7 @@ var ConfigSet = (function () {
170
180
  var config = backports_1.backportJestConfig(this.logger, this._jestConfig);
171
181
  if (this.parentOptions) {
172
182
  var globals = config.globals || (config.globals = {});
173
- globals['ts-jest'] = __assign({}, this.parentOptions, globals['ts-jest']);
183
+ globals['ts-jest'] = __assign(__assign({}, this.parentOptions), globals['ts-jest']);
174
184
  }
175
185
  this.logger.debug({ jestConfig: config }, 'normalized jest config');
176
186
  return config;
@@ -198,6 +208,20 @@ var ConfigSet = (function () {
198
208
  value: tsConfigOpt,
199
209
  };
200
210
  }
211
+ var packageJsonOpt = options.packageJson;
212
+ var packageJson;
213
+ if (typeof packageJsonOpt === 'string' || packageJsonOpt == null || packageJsonOpt === true) {
214
+ packageJson = {
215
+ kind: 'file',
216
+ value: typeof packageJsonOpt === 'string' ? this.resolvePath(packageJsonOpt) : undefined,
217
+ };
218
+ }
219
+ else if (typeof packageJsonOpt === 'object') {
220
+ packageJson = {
221
+ kind: 'inline',
222
+ value: packageJsonOpt,
223
+ };
224
+ }
201
225
  var transformers = (options.astTransformers || []).map(function (mod) { return _this.resolvePath(mod, { nodeResolve: true }); });
202
226
  var babelConfigOpt = options.babelConfig;
203
227
  var babelConfig;
@@ -240,6 +264,7 @@ var ConfigSet = (function () {
240
264
  var stringifyContentPathRegex = normalizeRegex(options.stringifyContentPathRegex);
241
265
  var res = {
242
266
  tsConfig: tsConfig,
267
+ packageJson: packageJson,
243
268
  babelConfig: babelConfig,
244
269
  diagnostics: diagnostics,
245
270
  isolatedModules: !!options.isolatedModules,
@@ -271,7 +296,7 @@ var ConfigSet = (function () {
271
296
  get: function () {
272
297
  var modules = ['jest', this.tsJest.compiler];
273
298
  if (this.tsJest.babelConfig) {
274
- modules.push('@babel/core', 'babel-core', 'babel-jest');
299
+ modules.push('@babel/core', 'babel-jest');
275
300
  }
276
301
  return modules.reduce(function (map, name) {
277
302
  map[name] = get_package_version_1.getPackageVersion(name) || '-';
@@ -313,6 +338,19 @@ var ConfigSet = (function () {
313
338
  enumerable: true,
314
339
  configurable: true
315
340
  });
341
+ ConfigSet.loadConfig = function (base) {
342
+ var _a = importer_1.importer.babelCore(messages_1.ImportReasons.BabelJest), OptionManager = _a.OptionManager, loadPartialConfig = _a.loadPartialConfig, version = _a.version;
343
+ if (version && semver.satisfies(version, '>=6 <7')) {
344
+ delete base.cwd;
345
+ }
346
+ if (typeof loadPartialConfig === 'function') {
347
+ var partialConfig = loadPartialConfig(base);
348
+ if (partialConfig) {
349
+ return partialConfig.options;
350
+ }
351
+ }
352
+ return new OptionManager().init(base);
353
+ };
316
354
  Object.defineProperty(ConfigSet.prototype, "babel", {
317
355
  get: function () {
318
356
  var babelConfig = this.tsJest.babelConfig;
@@ -323,23 +361,13 @@ var ConfigSet = (function () {
323
361
  var base = { cwd: this.cwd };
324
362
  if (babelConfig.kind === 'file') {
325
363
  if (babelConfig.value) {
326
- base = __assign({}, base, json5_1.default.parse(fs_1.readFileSync(babelConfig.value, 'utf8')));
364
+ base = __assign(__assign({}, base), json5.parse(fs_1.readFileSync(babelConfig.value, 'utf8')));
327
365
  }
328
366
  }
329
367
  else if (babelConfig.kind === 'inline') {
330
- base = __assign({}, base, babelConfig.value);
331
- }
332
- var _a = importer_1.importer.babelCore(messages_1.ImportReasons.BabelJest), OptionManager = _a.OptionManager, loadOptions = _a.loadOptions, version = _a.version;
333
- if (version && semver_1.default.satisfies(version, '>=6 <7')) {
334
- delete base.cwd;
335
- }
336
- var config;
337
- if (typeof loadOptions === 'function') {
338
- config = loadOptions(base);
339
- }
340
- else {
341
- config = new OptionManager().init(base);
368
+ base = __assign(__assign({}, base), babelConfig.value);
342
369
  }
370
+ var config = ConfigSet.loadConfig(base);
343
371
  this.logger.debug({ babelConfig: config }, 'normalized babel config');
344
372
  return config;
345
373
  },
@@ -504,7 +532,9 @@ var ConfigSet = (function () {
504
532
  declarationDir: undefined,
505
533
  declarationMap: undefined,
506
534
  emitDeclarationOnly: undefined,
535
+ incremental: undefined,
507
536
  sourceRoot: undefined,
537
+ tsBuildInfoFile: undefined,
508
538
  };
509
539
  if (!this.tsJest.babelConfig) {
510
540
  options.module = this.compilerModule.ModuleKind.CommonJS;
@@ -605,11 +635,11 @@ var ConfigSet = (function () {
605
635
  };
606
636
  }
607
637
  config = result_1.config;
608
- input = __assign({}, result_1.config, { compilerOptions: __assign({}, (result_1.config && result_1.config.compilerOptions), compilerOptions) });
638
+ input = __assign(__assign({}, result_1.config), { compilerOptions: __assign(__assign({}, (result_1.config && result_1.config.compilerOptions)), compilerOptions) });
609
639
  basePath = normalize_slashes_1.normalizeSlashes(path_1.dirname(configFileName));
610
640
  }
611
641
  }
612
- config.compilerOptions = __assign({}, config.compilerOptions, compilerOptions);
642
+ config.compilerOptions = __assign(__assign({}, config.compilerOptions), compilerOptions);
613
643
  var result = ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, configFileName);
614
644
  var forcedOptions = this.overriddenCompilerOptions;
615
645
  var finalOptions = result.options;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="jest" />
2
2
  export interface TsJestPresets {
3
3
  transform: Record<string, string>;
4
- testMatch: string[];
5
- moduleFileExtensions: string[];
4
+ testMatch?: string[];
5
+ moduleFileExtensions?: string[];
6
6
  }
7
7
  export interface CreateJestPresetOptions {
8
8
  allowJs?: boolean;
@@ -10,48 +10,14 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __read = (this && this.__read) || function (o, n) {
14
- var m = typeof Symbol === "function" && o[Symbol.iterator];
15
- if (!m) return o;
16
- var i = m.call(o), r, ar = [], e;
17
- try {
18
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
- }
20
- catch (error) { e = { error: error }; }
21
- finally {
22
- try {
23
- if (r && !r.done && (m = i["return"])) m.call(i);
24
- }
25
- finally { if (e) throw e.error; }
26
- }
27
- return ar;
28
- };
29
- var __spread = (this && this.__spread) || function () {
30
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
31
- return ar;
32
- };
33
13
  Object.defineProperty(exports, "__esModule", { value: true });
34
14
  var logger_1 = require("../util/logger");
35
- var jest_config_resolver_1 = require("./jest-config-resolver");
36
15
  var logger = logger_1.rootLogger.child({ namespace: 'jest-preset' });
37
- var jestConfigPkg = jest_config_resolver_1.getJestConfigPkg(logger);
38
- var defaults = jestConfigPkg.defaults || {
39
- transform: null,
40
- testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'],
41
- moduleFileExtensions: ['js', 'json', 'jsx', 'node'],
42
- };
43
16
  function createJestPreset(_a, from) {
44
- var _b = (_a === void 0 ? {} : _a).allowJs, allowJs = _b === void 0 ? false : _b;
45
- var _c;
17
+ var _b;
18
+ var _c = (_a === void 0 ? {} : _a).allowJs, allowJs = _c === void 0 ? false : _c;
19
+ if (from === void 0) { from = {}; }
46
20
  logger.debug({ allowJs: allowJs }, 'creating jest presets', allowJs ? 'handling' : 'not handling', 'JavaScript files');
47
- from = __assign({}, defaults, from);
48
- return {
49
- transform: __assign({}, from.transform, (_c = {}, _c[allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$'] = 'ts-jest', _c)),
50
- testMatch: dedup(__spread((from.testMatch || []), ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'])),
51
- moduleFileExtensions: dedup(__spread((from.moduleFileExtensions || []), ['ts', 'tsx'])),
52
- };
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));
53
22
  }
54
23
  exports.createJestPreset = createJestPreset;
55
- function dedup(array) {
56
- return array.filter(function (e, i, a) { return a.indexOf(e) === i; });
57
- }
@@ -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;
@@ -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];
@@ -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;
@@ -11,6 +12,7 @@ export declare type BabelJestTransformer = {
11
12
  export declare type BabelConfig = _babel.TransformOptions;
12
13
  export interface TsJestGlobalOptions {
13
14
  tsConfig?: boolean | string | CompilerOptions;
15
+ packageJson?: boolean | string | object;
14
16
  isolatedModules?: boolean;
15
17
  compiler?: string;
16
18
  astTransformers?: string[];
@@ -47,9 +49,19 @@ interface TsJestConfig$babelConfig$inline {
47
49
  value: BabelConfig;
48
50
  }
49
51
  declare type TsJestConfig$babelConfig = TsJestConfig$babelConfig$file | TsJestConfig$babelConfig$inline | undefined;
52
+ interface TsJestConfig$packageJson$file {
53
+ kind: 'file';
54
+ value: string | undefined;
55
+ }
56
+ interface TsJestConfig$packageJson$inline {
57
+ kind: 'inline';
58
+ value: any;
59
+ }
60
+ declare type TsJestConfig$packageJson = TsJestConfig$packageJson$file | TsJestConfig$packageJson$inline | undefined;
50
61
  declare type TsJestConfig$stringifyContentPathRegex = string | undefined;
51
62
  export interface TsJestConfig {
52
63
  tsConfig: TsJestConfig$tsConfig;
64
+ packageJson: TsJestConfig$packageJson;
53
65
  isolatedModules: boolean;
54
66
  compiler: string;
55
67
  diagnostics: TsJestConfig$diagnostics;
@@ -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) {
@@ -36,15 +36,7 @@ var __spread = (this && this.__spread) || function () {
36
36
  for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
37
37
  return ar;
38
38
  };
39
- var __importStar = (this && this.__importStar) || function (mod) {
40
- if (mod && mod.__esModule) return mod;
41
- var result = {};
42
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
43
- result["default"] = mod;
44
- return result;
45
- };
46
39
  Object.defineProperty(exports, "__esModule", { value: true });
47
- var hacks = __importStar(require("./hacks"));
48
40
  var logger_1 = require("./logger");
49
41
  var memoize_1 = require("./memoize");
50
42
  var messages_1 = require("./messages");
@@ -63,7 +55,6 @@ var Importer = (function () {
63
55
  get: function () {
64
56
  logger.debug('creating Importer singleton');
65
57
  return new Importer({
66
- 'babel-core': [passThru(version_checkers_1.VersionCheckers.babelCoreLegacy.warn), hacks.patchBabelCore_githubIssue6577],
67
58
  '@babel/core': [passThru(version_checkers_1.VersionCheckers.babelCore.warn)],
68
59
  'babel-jest': [passThru(version_checkers_1.VersionCheckers.babelJest.warn)],
69
60
  typescript: [passThru(version_checkers_1.VersionCheckers.typescript.warn)],
@@ -74,20 +65,10 @@ var Importer = (function () {
74
65
  configurable: true
75
66
  });
76
67
  Importer.prototype.babelJest = function (why) {
77
- this.tryThese('babel-core');
78
68
  return this._import(why, 'babel-jest');
79
69
  };
80
70
  Importer.prototype.babelCore = function (why) {
81
- return this._import(why, 'babel-core', {
82
- alternatives: ['@babel/core'],
83
- installTip: [
84
- {
85
- label: 'for Babel 7',
86
- module: "babel-jest 'babel-core@^7.0.0-0' @babel/core",
87
- },
88
- { label: 'for Babel 6', module: 'babel-jest babel-core' },
89
- ],
90
- });
71
+ return this._import(why, '@babel/core');
91
72
  };
92
73
  Importer.prototype.typescript = function (why, which) {
93
74
  return this._import(why, which);
@@ -14,7 +14,6 @@ var Errors;
14
14
  Errors["NotMappingMultiStarPath"] = "Not mapping \"{{path}}\" because it has more than one star (`*`).";
15
15
  Errors["NotMappingPathWithEmptyMap"] = "Not mapping \"{{path}}\" because it has no target.";
16
16
  Errors["MappingOnlyFirstTargetOfPath"] = "Mapping only to first target of \"{{path}}\" because it has more than one ({{count}}).";
17
- Errors["CannotPatchBabelCore6"] = "Error while trying to patch babel-core/lib/transformation/file: {{error}}";
18
17
  Errors["GotJsFileButAllowJsFalse"] = "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";
19
18
  Errors["GotUnknownFileTypeWithoutBabel"] = "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore.";
20
19
  Errors["GotUnknownFileTypeWithBabel"] = "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files.";
@@ -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; }
@@ -7,17 +7,15 @@ var messages_1 = require("./messages");
7
7
  var logger = logger_1.rootLogger.child({ namespace: 'versions' });
8
8
  var ExpectedVersions;
9
9
  (function (ExpectedVersions) {
10
- ExpectedVersions["Jest"] = ">=22 <24";
10
+ ExpectedVersions["Jest"] = ">=24 <25";
11
11
  ExpectedVersions["TypeScript"] = ">=2.7 <4";
12
- ExpectedVersions["BabelJest"] = ">=22 <24";
13
- ExpectedVersions["BabelCoreLegacy"] = ">=6 <7 || 7.0.0-bridge.0";
12
+ ExpectedVersions["BabelJest"] = ">=24 <25";
14
13
  ExpectedVersions["BabelCore"] = ">=7.0.0-beta.0 <8";
15
14
  })(ExpectedVersions = exports.ExpectedVersions || (exports.ExpectedVersions = {}));
16
15
  exports.VersionCheckers = {
17
16
  jest: createVersionChecker('jest', ExpectedVersions.Jest),
18
17
  typescript: createVersionChecker('typescript', ExpectedVersions.TypeScript),
19
18
  babelJest: createVersionChecker('babel-jest', ExpectedVersions.BabelJest),
20
- babelCoreLegacy: createVersionChecker('babel-core', ExpectedVersions.BabelCoreLegacy),
21
19
  babelCore: createVersionChecker('@babel/core', ExpectedVersions.BabelCore),
22
20
  };
23
21
  function checkVersion(name, expectedRange, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "23.10.5",
3
+ "version": "24.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": "cli.js",
@@ -32,9 +32,6 @@
32
32
  "changelog": "node_modules/.bin/conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
33
33
  "prepare": "npm run build",
34
34
  "prepublishOnly": "npm run test",
35
- "commitmsg": "node_modules/.bin/commitlint -E GIT_PARAMS",
36
- "precommit": "node_modules/.bin/lint-staged",
37
- "postcommit": "git reset",
38
35
  "preversion": "npm run test",
39
36
  "version": "npm run changelog && git add CHANGELOG.md"
40
37
  },
@@ -62,6 +59,7 @@
62
59
  "bs-logger": "0.x",
63
60
  "buffer-from": "1.x",
64
61
  "fast-json-stable-stringify": "2.x",
62
+ "lodash.memoize": "4.x",
65
63
  "json5": "2.x",
66
64
  "make-error": "1.x",
67
65
  "mkdirp": "0.x",
@@ -70,10 +68,17 @@
70
68
  "yargs-parser": "10.x"
71
69
  },
72
70
  "peerDependencies": {
73
- "jest": ">=22 <24"
71
+ "jest": ">=24 <25"
72
+ },
73
+ "husky": {
74
+ "hooks": {
75
+ "pre-commit": "lint-staged",
76
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
77
+ "post-commit": "git reset"
78
+ }
74
79
  },
75
80
  "devDependencies": {
76
- "@commitlint/cli": "7.x",
81
+ "@commitlint/cli": "8.x",
77
82
  "@commitlint/config-conventional": "7.x",
78
83
  "@types/babel__core": "7.x",
79
84
  "@types/buffer-from": "latest",
@@ -95,11 +100,10 @@
95
100
  "eslint": "latest",
96
101
  "fs-extra": "latest",
97
102
  "glob-gitignore": "latest",
98
- "husky": "0.x",
99
- "jest": "23.x",
103
+ "husky": "1.x",
104
+ "jest": "24.x",
100
105
  "js-yaml": "latest",
101
106
  "lint-staged": "latest",
102
- "lodash.memoize": "4.x",
103
107
  "lodash.merge": "4.x",
104
108
  "lodash.set": "4.x",
105
109
  "npm-run-all": "latest",
@@ -111,16 +115,14 @@
111
115
  "typescript": "3.x"
112
116
  },
113
117
  "lint-staged": {
114
- "linters": {
115
- "*.{ts,tsx}": [
116
- "tslint --fix",
117
- "git add"
118
- ],
119
- "*.{js,jsx}": [
120
- "eslint --fix",
121
- "git add"
122
- ]
123
- }
118
+ "*.{ts,tsx}": [
119
+ "tslint --fix",
120
+ "git add"
121
+ ],
122
+ "*.{js,jsx}": [
123
+ "eslint --fix",
124
+ "git add"
125
+ ]
124
126
  },
125
127
  "engines": {
126
128
  "node": ">= 6"
package/.gitattributes DELETED
@@ -1,2 +0,0 @@
1
- package-lock.json -diff -merge
2
- package-lock.json linguist-generated=true
@@ -1,2 +0,0 @@
1
- import { Logger } from 'bs-logger';
2
- export declare function getJestConfigPkg<TJestConfig>(logger: Logger): TJestConfig;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var fs_1 = require("fs");
4
- var path_1 = require("path");
5
- var resolve_1 = require("resolve");
6
- var messages_1 = require("../util/messages");
7
- function getJestConfigPkg(logger) {
8
- try {
9
- var jestPath = resolvePackagePath('jest', __dirname);
10
- var jestCliPath = resolvePackagePath('jest-cli', jestPath);
11
- var jestConfigPath = resolvePackagePath('jest-config', jestCliPath);
12
- var jestConfigPackageJson = require(path_1.join(jestConfigPath, 'package.json'));
13
- var jestConfigMainPath = path_1.resolve(jestConfigPath, jestConfigPackageJson.main);
14
- return require(jestConfigMainPath);
15
- }
16
- catch (error) {
17
- logger.error({ error: error }, messages_1.Errors.UnableToResolveJestConfig);
18
- return {};
19
- }
20
- }
21
- exports.getJestConfigPkg = getJestConfigPkg;
22
- function resolvePackagePath(packageName, baseDir) {
23
- var packageJsonPath = resolve_1.sync(packageName, {
24
- basedir: baseDir,
25
- packageFilter: function (packageJson) {
26
- packageJson.main = 'package.json';
27
- return packageJson;
28
- },
29
- readFileSync: fs_1.readFileSync,
30
- isFile: isFile,
31
- });
32
- var realPackageJsonPath = fs_1.realpathSync(packageJsonPath);
33
- return path_1.dirname(realPackageJsonPath);
34
- }
35
- function isFile(filePath) {
36
- if (fs_1.existsSync(filePath)) {
37
- var stats = fs_1.statSync(filePath);
38
- return stats.isFile();
39
- }
40
- else {
41
- return false;
42
- }
43
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var semver_1 = __importDefault(require("semver"));
7
- var logger_1 = require("./logger");
8
- var messages_1 = require("./messages");
9
- var logger = logger_1.rootLogger.child({ namespace: 'hacks' });
10
- exports.patchBabelCore_githubIssue6577 = function (babel) {
11
- if (typeof babel.version !== 'string')
12
- return babel;
13
- var version = semver_1.default.coerce(babel.version);
14
- if (version && version.major === 6) {
15
- var flag = Symbol.for('ts-jest:patchBabelCore_githubIssue6577');
16
- try {
17
- var File = require('babel-core/lib/transformation/file').File;
18
- if (File.prototype.initOptions[flag])
19
- return babel;
20
- File.prototype.initOptions = (function (original) {
21
- return function initOptions(opt) {
22
- var before = opt.sourceMaps;
23
- var result = original.apply(this, arguments);
24
- if (before && before !== result.sourceMaps) {
25
- result.sourceMaps = before;
26
- }
27
- return result;
28
- };
29
- })(File.prototype.initOptions);
30
- Object.defineProperty(File.prototype.initOptions, flag, { value: true });
31
- logger.info('patched babel-core/lib/transformation/file');
32
- }
33
- catch (error) {
34
- logger.warn({ error: error }, messages_1.interpolate(messages_1.Errors.CannotPatchBabelCore6, { error: error.message }));
35
- }
36
- }
37
- return babel;
38
- };
package/icon.png DELETED
Binary file