ts-jest 23.10.5 → 24.0.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
+ a088f4bb81d7f5f72d2907fcf9d998cc1aa136a8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
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.0.0"></a>
2
+ # [24.0.0](https://github.com/kulshekhar/ts-jest/compare/v23.10.5...v24.0.0) (2019-02-18)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * cli test ([1d67101](https://github.com/kulshekhar/ts-jest/commit/1d67101))
8
+ * module tests and some snapshots ([999f889](https://github.com/kulshekhar/ts-jest/commit/999f889))
9
+ * remove unused snapshots ([108b08b](https://github.com/kulshekhar/ts-jest/commit/108b08b))
10
+ * some tests ([d0f2231](https://github.com/kulshekhar/ts-jest/commit/d0f2231))
11
+ * test command ([8372b5e](https://github.com/kulshekhar/ts-jest/commit/8372b5e))
12
+ * test path for windows (attempt 1) ([6824ac4](https://github.com/kulshekhar/ts-jest/commit/6824ac4))
13
+ * test path for windows (attempt 2) ([eb2fc8a](https://github.com/kulshekhar/ts-jest/commit/eb2fc8a))
14
+
15
+
16
+ ### Features
17
+
18
+ * **jest:** bump to 24 ([defcb77](https://github.com/kulshekhar/ts-jest/commit/defcb77))
3
19
 
4
20
 
5
21
 
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
 
@@ -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;
@@ -271,7 +271,7 @@ var ConfigSet = (function () {
271
271
  get: function () {
272
272
  var modules = ['jest', this.tsJest.compiler];
273
273
  if (this.tsJest.babelConfig) {
274
- modules.push('@babel/core', 'babel-core', 'babel-jest');
274
+ modules.push('@babel/core', 'babel-jest');
275
275
  }
276
276
  return modules.reduce(function (map, name) {
277
277
  map[name] = get_package_version_1.getPackageVersion(name) || '-';
@@ -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
17
  var _b = (_a === void 0 ? {} : _a).allowJs, allowJs = _b === void 0 ? false : _b;
18
+ if (from === void 0) { from = {}; }
45
19
  var _c;
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({ 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));
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
- }
@@ -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.";
@@ -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.0.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
  },
@@ -70,7 +67,14 @@
70
67
  "yargs-parser": "10.x"
71
68
  },
72
69
  "peerDependencies": {
73
- "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
+ }
74
78
  },
75
79
  "devDependencies": {
76
80
  "@commitlint/cli": "7.x",
@@ -95,8 +99,8 @@
95
99
  "eslint": "latest",
96
100
  "fs-extra": "latest",
97
101
  "glob-gitignore": "latest",
98
- "husky": "0.x",
99
- "jest": "23.x",
102
+ "husky": "1.x",
103
+ "jest": "24.x",
100
104
  "js-yaml": "latest",
101
105
  "lint-staged": "latest",
102
106
  "lodash.memoize": "4.x",
@@ -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
- };