ts-jest 23.10.4 → 24.0.2

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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ package-lock.json -diff -merge
2
+ package-lock.json linguist-generated=true
package/.ts-jest-digest CHANGED
@@ -1 +1 @@
1
- c92057ca8c4a5c745979bfa0e6a09302a19dc4b3
1
+ 0aceab77a1f613fedb22a0395a65327e834ef35c
package/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ <a name="24.0.2"></a>
2
+ ## [24.0.2](https://github.com/kulshekhar/ts-jest/compare/v24.0.1...v24.0.2) (2019-04-05)
3
+
4
+
5
+
6
+ <a name="24.0.1"></a>
7
+ ## [24.0.1](https://github.com/kulshekhar/ts-jest/compare/v24.0.0...v24.0.1) (2019-03-30)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * 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))
13
+
14
+
15
+ ### Features
16
+
17
+ * **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))
18
+
19
+
20
+
21
+ <a name="24.0.0"></a>
22
+ # [24.0.0](https://github.com/kulshekhar/ts-jest/compare/v23.10.5...v24.0.0) (2019-02-18)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * cli test ([1d67101](https://github.com/kulshekhar/ts-jest/commit/1d67101))
28
+ * module tests and some snapshots ([999f889](https://github.com/kulshekhar/ts-jest/commit/999f889))
29
+ * remove unused snapshots ([108b08b](https://github.com/kulshekhar/ts-jest/commit/108b08b))
30
+ * some tests ([d0f2231](https://github.com/kulshekhar/ts-jest/commit/d0f2231))
31
+ * test command ([8372b5e](https://github.com/kulshekhar/ts-jest/commit/8372b5e))
32
+ * test path for windows (attempt 1) ([6824ac4](https://github.com/kulshekhar/ts-jest/commit/6824ac4))
33
+ * test path for windows (attempt 2) ([eb2fc8a](https://github.com/kulshekhar/ts-jest/commit/eb2fc8a))
34
+
35
+
36
+ ### Features
37
+
38
+ * **jest:** bump to 24 ([defcb77](https://github.com/kulshekhar/ts-jest/commit/defcb77))
39
+
40
+
41
+
1
42
  <a name="23.10.4"></a>
2
43
  ## [23.10.4](https://github.com/kulshekhar/ts-jest/compare/v23.10.3...v23.10.4) (2018-10-06)
3
44
 
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 **DOT 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. 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).
50
50
 
51
51
  ## Authors/maintainers
52
52
 
@@ -131,7 +131,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
131
131
  if (preset)
132
132
  migratedConfig.preset = preset.name;
133
133
  if (migratedConfig.moduleFileExtensions && migratedConfig.moduleFileExtensions.length && preset) {
134
- presetValue = dedupSort(preset.value.moduleFileExtensions).join('::');
134
+ presetValue = dedupSort(preset.value.moduleFileExtensions || []).join('::');
135
135
  migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::');
136
136
  if (presetValue === migratedValue) {
137
137
  delete migratedConfig.moduleFileExtensions;
@@ -141,7 +141,7 @@ exports.run = function (args) { return __awaiter(_this, void 0, void 0, function
141
141
  migratedConfig.testMatch = null;
142
142
  }
143
143
  else if (migratedConfig.testMatch && migratedConfig.testMatch.length && preset) {
144
- presetValue = dedupSort(preset.value.testMatch).join('::');
144
+ presetValue = dedupSort(preset.value.testMatch || []).join('::');
145
145
  migratedValue = dedupSort(migratedConfig.testMatch).join('::');
146
146
  if (presetValue === migratedValue) {
147
147
  delete migratedConfig.testMatch;
@@ -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;
@@ -134,19 +134,31 @@ var ConfigSet = (function () {
134
134
  }
135
135
  Object.defineProperty(ConfigSet.prototype, "projectPackageJson", {
136
136
  get: function () {
137
+ var packageJson = this.tsJest.packageJson;
138
+ if (packageJson && packageJson.kind === 'inline') {
139
+ return packageJson.value;
140
+ }
141
+ if (packageJson && packageJson.kind === 'file' && packageJson.value) {
142
+ var path = this.resolvePath(packageJson.value);
143
+ if (fs_1.existsSync(path)) {
144
+ return require(path);
145
+ }
146
+ this.logger.warn(messages_1.Errors.UnableToFindProjectRoot);
147
+ return {};
148
+ }
137
149
  var tsJestRoot = path_1.resolve(__dirname, '..', '..');
138
150
  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);
151
+ if (fs_1.existsSync(pkgPath)) {
152
+ return require(pkgPath);
153
+ }
154
+ if (fs_1.realpathSync(this.rootDir) === fs_1.realpathSync(tsJestRoot)) {
155
+ pkgPath = path_1.resolve(tsJestRoot, 'package.json');
156
+ if (fs_1.existsSync(pkgPath)) {
157
+ return require(pkgPath);
147
158
  }
148
159
  }
149
- return exists ? require(pkgPath) : {};
160
+ this.logger.warn(messages_1.Errors.UnableToFindProjectRoot);
161
+ return {};
150
162
  },
151
163
  enumerable: true,
152
164
  configurable: true
@@ -198,6 +210,20 @@ var ConfigSet = (function () {
198
210
  value: tsConfigOpt,
199
211
  };
200
212
  }
213
+ var packageJsonOpt = options.packageJson;
214
+ var packageJson;
215
+ if (typeof packageJsonOpt === 'string' || packageJsonOpt == null || packageJsonOpt === true) {
216
+ packageJson = {
217
+ kind: 'file',
218
+ value: typeof packageJsonOpt === 'string' ? this.resolvePath(packageJsonOpt) : undefined,
219
+ };
220
+ }
221
+ else if (typeof packageJsonOpt === 'object') {
222
+ packageJson = {
223
+ kind: 'inline',
224
+ value: packageJsonOpt,
225
+ };
226
+ }
201
227
  var transformers = (options.astTransformers || []).map(function (mod) { return _this.resolvePath(mod, { nodeResolve: true }); });
202
228
  var babelConfigOpt = options.babelConfig;
203
229
  var babelConfig;
@@ -240,6 +266,7 @@ var ConfigSet = (function () {
240
266
  var stringifyContentPathRegex = normalizeRegex(options.stringifyContentPathRegex);
241
267
  var res = {
242
268
  tsConfig: tsConfig,
269
+ packageJson: packageJson,
243
270
  babelConfig: babelConfig,
244
271
  diagnostics: diagnostics,
245
272
  isolatedModules: !!options.isolatedModules,
@@ -271,7 +298,7 @@ var ConfigSet = (function () {
271
298
  get: function () {
272
299
  var modules = ['jest', this.tsJest.compiler];
273
300
  if (this.tsJest.babelConfig) {
274
- modules.push('@babel/core', 'babel-core', 'babel-jest');
301
+ modules.push('@babel/core', 'babel-jest');
275
302
  }
276
303
  return modules.reduce(function (map, name) {
277
304
  map[name] = get_package_version_1.getPackageVersion(name) || '-';
@@ -313,6 +340,19 @@ var ConfigSet = (function () {
313
340
  enumerable: true,
314
341
  configurable: true
315
342
  });
343
+ ConfigSet.loadConfig = function (base) {
344
+ 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')) {
346
+ delete base.cwd;
347
+ }
348
+ if (typeof loadPartialConfig === 'function') {
349
+ var partialConfig = loadPartialConfig(base);
350
+ if (partialConfig) {
351
+ return partialConfig.options;
352
+ }
353
+ }
354
+ return new OptionManager().init(base);
355
+ };
316
356
  Object.defineProperty(ConfigSet.prototype, "babel", {
317
357
  get: function () {
318
358
  var babelConfig = this.tsJest.babelConfig;
@@ -329,17 +369,7 @@ var ConfigSet = (function () {
329
369
  else if (babelConfig.kind === 'inline') {
330
370
  base = __assign({}, base, babelConfig.value);
331
371
  }
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);
342
- }
372
+ var config = ConfigSet.loadConfig(base);
343
373
  this.logger.debug({ babelConfig: config }, 'normalized babel config');
344
374
  return config;
345
375
  },
@@ -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,54 +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
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
37
- result["default"] = mod;
38
- return result;
39
- };
40
13
  Object.defineProperty(exports, "__esModule", { value: true });
41
- var jestConfig = __importStar(require("jest-config"));
42
14
  var logger_1 = require("../util/logger");
43
15
  var logger = logger_1.rootLogger.child({ namespace: 'jest-preset' });
44
- var defaults = jestConfig.defaults || {
45
- transform: null,
46
- testMatch: ['**/__tests__/**/*.js?(x)', '**/?(*.)+(spec|test).js?(x)'],
47
- moduleFileExtensions: ['js', 'json', 'jsx', 'node'],
48
- };
49
16
  function createJestPreset(_a, from) {
50
17
  var _b = (_a === void 0 ? {} : _a).allowJs, allowJs = _b === void 0 ? false : _b;
18
+ if (from === void 0) { from = {}; }
51
19
  var _c;
52
20
  logger.debug({ allowJs: allowJs }, 'creating jest presets', allowJs ? 'handling' : 'not handling', 'JavaScript files');
53
- from = __assign({}, defaults, from);
54
- return {
55
- transform: __assign({}, from.transform, (_c = {}, _c[allowJs ? '^.+\\.[tj]sx?$' : '^.+\\.tsx?$'] = 'ts-jest', _c)),
56
- testMatch: dedup(__spread((from.testMatch || []), ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'])),
57
- moduleFileExtensions: dedup(__spread((from.moduleFileExtensions || []), ['ts', 'tsx'])),
58
- };
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));
59
22
  }
60
23
  exports.createJestPreset = createJestPreset;
61
- function dedup(array) {
62
- return array.filter(function (e, i, a) { return a.indexOf(e) === i; });
63
- }
package/dist/types.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare type BabelJestTransformer = {
11
11
  export declare type BabelConfig = _babel.TransformOptions;
12
12
  export interface TsJestGlobalOptions {
13
13
  tsConfig?: boolean | string | CompilerOptions;
14
+ packageJson?: boolean | string | object;
14
15
  isolatedModules?: boolean;
15
16
  compiler?: string;
16
17
  astTransformers?: string[];
@@ -47,9 +48,19 @@ interface TsJestConfig$babelConfig$inline {
47
48
  value: BabelConfig;
48
49
  }
49
50
  declare type TsJestConfig$babelConfig = TsJestConfig$babelConfig$file | TsJestConfig$babelConfig$inline | undefined;
51
+ interface TsJestConfig$packageJson$file {
52
+ kind: 'file';
53
+ value: string | undefined;
54
+ }
55
+ interface TsJestConfig$packageJson$inline {
56
+ kind: 'inline';
57
+ value: any;
58
+ }
59
+ declare type TsJestConfig$packageJson = TsJestConfig$packageJson$file | TsJestConfig$packageJson$inline | undefined;
50
60
  declare type TsJestConfig$stringifyContentPathRegex = string | undefined;
51
61
  export interface TsJestConfig {
52
62
  tsConfig: TsJestConfig$tsConfig;
63
+ packageJson: TsJestConfig$packageJson;
53
64
  isolatedModules: boolean;
54
65
  compiler: string;
55
66
  diagnostics: TsJestConfig$diagnostics;
@@ -95,4 +106,7 @@ export interface AstTransformerDesc {
95
106
  version: number;
96
107
  factory(cs: ConfigSet): TransformerFactory<SourceFile>;
97
108
  }
109
+ export interface IPackageJson {
110
+ main: string;
111
+ }
98
112
  export {};
@@ -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,12 +14,12 @@ 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.";
21
20
  Errors["ConfigNoModuleInterop"] = "If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information.";
22
21
  Errors["UnableToFindProjectRoot"] = "Unable to find the root of the project where ts-jest has been installed.";
22
+ Errors["UnableToResolveJestConfig"] = "Unable to resolve jest-config. Ensure Jest is properly installed.";
23
23
  })(Errors = exports.Errors || (exports.Errors = {}));
24
24
  var Helps;
25
25
  (function (Helps) {
@@ -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 {};
@@ -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.4",
3
+ "version": "24.0.2",
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
  },
@@ -65,11 +62,19 @@
65
62
  "json5": "2.x",
66
63
  "make-error": "1.x",
67
64
  "mkdirp": "0.x",
65
+ "resolve": "1.x",
68
66
  "semver": "^5.5",
69
67
  "yargs-parser": "10.x"
70
68
  },
71
69
  "peerDependencies": {
72
- "jest": ">=22 <24"
70
+ "jest": ">=24 <25"
71
+ },
72
+ "husky": {
73
+ "hooks": {
74
+ "pre-commit": "lint-staged",
75
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
76
+ "post-commit": "git reset"
77
+ }
73
78
  },
74
79
  "devDependencies": {
75
80
  "@commitlint/cli": "7.x",
@@ -86,6 +91,7 @@
86
91
  "@types/lodash.set": "4.x",
87
92
  "@types/mkdirp": "latest",
88
93
  "@types/node": "10.x",
94
+ "@types/resolve": "latest",
89
95
  "@types/semver": "latest",
90
96
  "@types/yargs": "latest",
91
97
  "conventional-changelog-cli": "2.x",
@@ -93,8 +99,8 @@
93
99
  "eslint": "latest",
94
100
  "fs-extra": "latest",
95
101
  "glob-gitignore": "latest",
96
- "husky": "0.x",
97
- "jest": "23.x",
102
+ "husky": "1.x",
103
+ "jest": "24.x",
98
104
  "js-yaml": "latest",
99
105
  "lint-staged": "latest",
100
106
  "lodash.memoize": "4.x",
@@ -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
- };