ts-jest 27.0.4 → 27.0.5

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
- 728a5836db2d1522482a6d839e7cb4bf9dc045c0
1
+ df3ae8b1c1562a3bb93465ae542aa416874eb4e7
package/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## [27.0.5](https://github.com/kulshekhar/ts-jest/compare/v27.0.4...v27.0.5) (2021-08-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **cli:** add migration `tsConfig` option for `ts-jest` config options ([#2794](https://github.com/kulshekhar/ts-jest/issues/2794)) ([781710b](https://github.com/kulshekhar/ts-jest/commit/781710bf6b84853fffbb02543062a726fe1ad9c2)), closes [#2764](https://github.com/kulshekhar/ts-jest/issues/2764)
7
+ * **cli:** fix `config:init` genarate invalid type comment ([#2773](https://github.com/kulshekhar/ts-jest/issues/2773)) ([ede8a20](https://github.com/kulshekhar/ts-jest/commit/ede8a2061e20b717c0d56e4d81a3cd0ec7db8b1a)), closes [#2772](https://github.com/kulshekhar/ts-jest/issues/2772)
8
+ * **config:** handle `./` in tsconfig `paths` for `pathsToModuleNameMapper` ([#2797](https://github.com/kulshekhar/ts-jest/issues/2797)) ([42ff5e4](https://github.com/kulshekhar/ts-jest/commit/42ff5e469fb5d315b92e85eee105e5a040949c01)), closes [#2709](https://github.com/kulshekhar/ts-jest/issues/2709)
9
+
10
+
11
+ ### Code Refactoring
12
+
13
+ * use native `Buffer.from` and `mkdird` ([#2774](https://github.com/kulshekhar/ts-jest/issues/2774)) ([4869660](https://github.com/kulshekhar/ts-jest/commit/4869660e3917deb063745c5acaf079123d6d2ca8))
14
+
15
+
16
+
1
17
  ## [27.0.4](https://github.com/kulshekhar/ts-jest/compare/v27.0.3...v27.0.4) (2021-07-21)
2
18
 
3
19
 
@@ -10,7 +10,7 @@ Cannot find module "" from ""
10
10
 
11
11
  - Check if `rootDir` is referenced correctly. If not add this on your existing jest configuration.
12
12
 
13
- ```javascipt
13
+ ```javascript
14
14
  module.exports = {
15
15
  ...
16
16
  roots: ["<rootDir>"]
@@ -19,7 +19,7 @@ module.exports = {
19
19
 
20
20
  - Check if module directories are included on your jest configuration. If not add this on your existing jest configuration.
21
21
 
22
- ```javascipt
22
+ ```javascript
23
23
  module.exports = {
24
24
  ...
25
25
  moduleDirectories: ["node_modules","<module-directory>"],
@@ -29,7 +29,7 @@ module.exports = {
29
29
 
30
30
  - Check if module name is properly mapped and can be referenced by jest. If not, you can define moduleNameMapper for your jest configuration.
31
31
 
32
- ```javascipt
32
+ ```javascript
33
33
  module.exports = {
34
34
  ...
35
35
  moduleNameMapper: {
@@ -39,3 +39,37 @@ module.exports = {
39
39
  ```
40
40
 
41
41
  - Check github folder names if its identical to you local folder names. Sometimes github never updates your folder names even if you rename it locally. If this happens rename your folders via github or use this command `git mv <source> <destination>` and commit changes.
42
+
43
+ ## Transform (node)-module explicitly
44
+
45
+ ### PROBLEM
46
+
47
+ SyntaxError: Cannot use import statement outside a module
48
+
49
+ ### SOLUTION
50
+
51
+ One of the node modules hasn't the correct syntax for Jests execution step. It needs to
52
+ be transformed first.
53
+
54
+ There is a good chance that the error message shows which module is affected:
55
+
56
+ ```shell
57
+ SyntaxError: Cannot use import statement outside a module
58
+ > 22 | import Component from "../../node_modules/some-module/lib";
59
+ | ^
60
+ ```
61
+
62
+ In this case **some-module** is the problem and needs to be transformed.
63
+ By adding the following line to the configuration file it will tell Jest which modules
64
+ shouldnt be ignored during the transformation step:
65
+
66
+ ```javascript
67
+ module.exports = {
68
+ ...
69
+ transformIgnorePatterns: ["node_modules/(?!(some-module|another-module))"]
70
+ };
71
+ ```
72
+
73
+ **some-module** and **another-module** will be transformed.
74
+
75
+ For more information see [here](https://stackoverflow.com/questions/63389757/jest-unit-test-syntaxerror-cannot-use-import-statement-outside-a-module) and [here](https://stackoverflow.com/questions/52035066/how-to-write-jest-transformignorepatterns).
@@ -119,7 +119,7 @@ var run = function (args) { return __awaiter(void 0, void 0, void 0, function ()
119
119
  if (!jestPreset) {
120
120
  content.push(preset.jsImport('tsjPreset') + ";", '');
121
121
  }
122
- content.push("/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */");
122
+ content.push("/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */");
123
123
  content.push('module.exports = {');
124
124
  if (jestPreset) {
125
125
  content.push(" preset: '" + preset.name + "',");
@@ -42,8 +42,9 @@ var pathsToModuleNameMapper = function (mapping, _a) {
42
42
  }
43
43
  else if (segments.length === 2) {
44
44
  var paths = toPaths.map(function (target) {
45
+ var enrichedTarget = target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target;
45
46
  var enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? prefix + "/" : prefix;
46
- return "" + enrichedPrefix + target.replace(/\*/g, '$1');
47
+ return "" + enrichedPrefix + enrichedTarget.replace(/\*/g, '$1');
47
48
  });
48
49
  pattern = "^" + escapeRegex(segments[0]) + "(.*)" + escapeRegex(segments[1]) + "$";
49
50
  jestMap[pattern] = paths.length === 1 ? paths[0] : paths;
@@ -31,14 +31,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
31
31
  to[j] = from[i];
32
32
  return to;
33
33
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
34
  Object.defineProperty(exports, "__esModule", { value: true });
38
35
  exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
39
36
  var fs_1 = require("fs");
40
37
  var path_1 = require("path");
41
- var mkdirp_1 = __importDefault(require("mkdirp"));
42
38
  var ts_jest_compiler_1 = require("./compiler/ts-jest-compiler");
43
39
  var config_set_1 = require("./config/config-set");
44
40
  var constants_1 = require("./constants");
@@ -210,7 +206,7 @@ var TsJestTransformer = (function () {
210
206
  TsJestTransformer.prototype._getFsCachedResolvedModules = function (configSet) {
211
207
  var cacheDir = configSet.tsCacheDir;
212
208
  if (!configSet.isolatedModules && cacheDir) {
213
- mkdirp_1.default.sync(cacheDir);
209
+ fs_1.mkdirSync(cacheDir, { recursive: true });
214
210
  this._tsResolvedModulesCachePath = path_1.join(cacheDir, sha1_1.sha1('ts-jest-resolved-modules', exports.CACHE_KEY_EL_SEPARATOR));
215
211
  try {
216
212
  var cachedTSResolvedModules = fs_1.readFileSync(this._tsResolvedModulesCachePath, 'utf-8');
@@ -56,6 +56,13 @@ var backportJestConfig = function (logger, config) {
56
56
  }
57
57
  delete tsJest.tsConfigFile;
58
58
  }
59
+ if ('tsConfig' in tsJest) {
60
+ warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig');
61
+ if (tsJest.tsConfig) {
62
+ mergeTsJest.tsconfig = tsJest.tsConfig;
63
+ }
64
+ delete tsJest.tsConfig;
65
+ }
59
66
  if ('enableTsDiagnostics' in tsJest) {
60
67
  warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics');
61
68
  if (tsJest.enableTsDiagnostics) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-jest",
3
- "version": "27.0.4",
3
+ "version": "27.0.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {
@@ -57,22 +57,20 @@
57
57
  "homepage": "https://kulshekhar.github.io/ts-jest",
58
58
  "dependencies": {
59
59
  "bs-logger": "0.x",
60
- "buffer-from": "1.x",
61
60
  "fast-json-stable-stringify": "2.x",
62
61
  "jest-util": "^27.0.0",
63
62
  "json5": "2.x",
64
63
  "lodash": "4.x",
65
64
  "make-error": "1.x",
66
- "mkdirp": "1.x",
67
65
  "semver": "7.x",
68
66
  "yargs-parser": "20.x"
69
67
  },
70
68
  "peerDependencies": {
71
- "jest": "^27.0.0",
72
- "typescript": ">=3.8 <5.0",
73
- "babel-jest": ">=27.0.0 <28",
74
69
  "@babel/core": ">=7.0.0-beta.0 <8",
75
- "@types/jest": "^26.0.0"
70
+ "@types/jest": "^27.0.0",
71
+ "babel-jest": ">=27.0.0 <28",
72
+ "jest": "^27.0.0",
73
+ "typescript": ">=3.8 <5.0"
76
74
  },
77
75
  "peerDependenciesMeta": {
78
76
  "babel-jest": {
@@ -93,20 +91,18 @@
93
91
  }
94
92
  },
95
93
  "devDependencies": {
96
- "@commitlint/cli": "12.x",
97
- "@commitlint/config-angular": "^12.0.0",
94
+ "@commitlint/cli": "13.x",
95
+ "@commitlint/config-angular": "^13.1.0",
98
96
  "@jest/transform": "^27.0.0",
99
97
  "@jest/types": "^27.0.0",
100
98
  "@types/babel__core": "7.x",
101
- "@types/buffer-from": "latest",
102
99
  "@types/cross-spawn": "latest",
103
100
  "@types/fs-extra": "latest",
104
101
  "@types/jest": "latest",
105
102
  "@types/js-yaml": "latest",
106
103
  "@types/lodash": "4.x",
107
104
  "@types/micromatch": "4.x",
108
- "@types/mkdirp": "latest",
109
- "@types/node": "16.4.0",
105
+ "@types/node": "16.6.1",
110
106
  "@types/node-fetch": "^2.5.8",
111
107
  "@types/react": "17.x",
112
108
  "@types/semver": "latest",