ts-jest 29.2.4 → 29.2.6
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 +1 -1
- package/CHANGELOG.md +22 -0
- package/CONTRIBUTING.md +1 -0
- package/LICENSE.md +1 -1
- package/README.md +1 -0
- package/TROUBLESHOOTING.md +1 -73
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +3 -3
- package/dist/legacy/compiler/ts-compiler.js +3 -3
- package/dist/presets/create-jest-preset.js +2 -2
- package/package.json +35 -36
- package/globals.d.ts +0 -18
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bc7eea511e438e06b762bdf538d9d2c6b362e922
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
### [29.2.6](https://github.com/kulshekhar/ts-jest/compare/v29.2.5...v29.2.6) (2025-02-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fix: escape dot for `JS_TRANSFORM_PATTERN` regex ([8c91c60](https://github.com/kulshekhar/ts-jest/commit/8c91c60))
|
|
7
|
+
* fix: escape dot for `TS_JS_TRANSFORM_PATTERN` regex ([3eea850](https://github.com/kulshekhar/ts-jest/commit/3eea850))
|
|
8
|
+
* fix: escape dot for `TS_TRANSFORM_PATTERN` regex ([80d3e4d](https://github.com/kulshekhar/ts-jest/commit/80d3e4d)), closes [#4579](https://github.com/kulshekhar/ts-jest/issues/4579)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### [29.2.5](https://github.com/kulshekhar/ts-jest/compare/v29.2.4...v29.2.5) (2024-08-23)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* build: build package with `NodeNext` module ([9b3ade5](https://github.com/kulshekhar/ts-jest/commit/9b3ade5))
|
|
18
|
+
* fix: set value `ts/tsx` `extensionsToTreatAsEsm` in default esm preset ([d9ff362](https://github.com/kulshekhar/ts-jest/commit/d9ff362))
|
|
19
|
+
* fix(compiler): fallback to `NodeJS` module resolution for ts 4.8 ([b7d3409](https://github.com/kulshekhar/ts-jest/commit/b7d3409)), closes [#4499](https://github.com/kulshekhar/ts-jest/issues/4499)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
1
23
|
### [29.2.4](https://github.com/kulshekhar/ts-jest/compare/v29.2.3...v29.2.4) (2024-08-01)
|
|
2
24
|
|
|
3
25
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -82,6 +82,7 @@ changes are being displayed accurately.
|
|
|
82
82
|
```sh-session
|
|
83
83
|
$ cd website # Only needed if you are not already in the website directory
|
|
84
84
|
$ npm ci
|
|
85
|
+
$ npm run lint-prettier # Please format markdown files
|
|
85
86
|
$ npm run start
|
|
86
87
|
```
|
|
87
88
|
3. You can run a development server to check if the changes you made are being displayed accurately by running `npm run start` in the website directory.
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
<a href="https://coveralls.io/github/kulshekhar/ts-jest?branch=main"><img src="https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=main" alt="Coverage status"/> </a>
|
|
10
10
|
<a href="https://actions-badge.atrox.dev/kulshekhar/ts-jest/goto?ref=main"><img alt="GitHub actions" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fkulshekhar%2Fts-jest%2Fbadge%3Fref%3Dmain&style=flat-square" /> </a>
|
|
11
11
|
<a href="https://github.com/kulshekhar/ts-jest/blob/main/LICENSE.md"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a>
|
|
12
|
+
<a href="https://gurubase.io/g/ts-jest"><img src="https://img.shields.io/badge/Gurubase-Ask%20ts--jest%20Guru-006BFF?style=flat-square" alt="Gurubase"/> </a>
|
|
12
13
|
</p>
|
|
13
14
|
|
|
14
15
|
<img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
|
package/TROUBLESHOOTING.md
CHANGED
|
@@ -1,75 +1,3 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
### PROBLEM
|
|
6
|
-
|
|
7
|
-
Cannot find module "" from ""
|
|
8
|
-
|
|
9
|
-
### SOLUTION
|
|
10
|
-
|
|
11
|
-
- Check if `rootDir` is referenced correctly. If not add this on your existing jest configuration.
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
module.exports = {
|
|
15
|
-
...
|
|
16
|
-
roots: ["<rootDir>"]
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
- Check if module directories are included on your jest configuration. If not add this on your existing jest configuration.
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
module.exports = {
|
|
24
|
-
...
|
|
25
|
-
moduleDirectories: ["node_modules","<module-directory>"],
|
|
26
|
-
modulePaths: ["<path-of-module>"],
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
module.exports = {
|
|
34
|
-
...
|
|
35
|
-
moduleNameMapper: {
|
|
36
|
-
"<import-path>": "<rootDir>/<real-physical-path>",
|
|
37
|
-
},
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
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).
|
|
3
|
+
Troubleshooting guide have been moved to https://kulshekhar.github.io/ts-jest/docs/guides/troubleshooting
|
package/dist/constants.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ export declare const DECLARATION_TYPE_EXT = ".d.ts";
|
|
|
3
3
|
export declare const JS_JSX_EXTENSIONS: string[];
|
|
4
4
|
export declare const TS_TSX_REGEX: RegExp;
|
|
5
5
|
export declare const JS_JSX_REGEX: RegExp;
|
|
6
|
-
export declare const TS_TRANSFORM_PATTERN = "
|
|
6
|
+
export declare const TS_TRANSFORM_PATTERN = "^.+\\.tsx?$";
|
|
7
7
|
export declare const ESM_TS_TRANSFORM_PATTERN = "^.+\\.m?tsx?$";
|
|
8
|
-
export declare const TS_JS_TRANSFORM_PATTERN = "
|
|
8
|
+
export declare const TS_JS_TRANSFORM_PATTERN = "^.+\\.[tj]sx?$";
|
|
9
9
|
export declare const ESM_TS_JS_TRANSFORM_PATTERN = "^.+\\.m?[tj]sx?$";
|
|
10
|
-
export declare const JS_TRANSFORM_PATTERN = "
|
|
10
|
+
export declare const JS_TRANSFORM_PATTERN = "^.+\\.jsx?$";
|
|
11
11
|
export declare const ESM_JS_TRANSFORM_PATTERN = "^.+\\.m?jsx?$";
|
|
12
12
|
export declare const TS_EXT_TO_TREAT_AS_ESM: string[];
|
|
13
13
|
export declare const JS_EXT_TO_TREAT_AS_ESM: string[];
|
package/dist/constants.js
CHANGED
|
@@ -6,11 +6,11 @@ exports.DECLARATION_TYPE_EXT = '.d.ts';
|
|
|
6
6
|
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
|
|
7
7
|
exports.TS_TSX_REGEX = /\.[cm]?tsx?$/;
|
|
8
8
|
exports.JS_JSX_REGEX = /\.[cm]?jsx?$/;
|
|
9
|
-
exports.TS_TRANSFORM_PATTERN = '
|
|
9
|
+
exports.TS_TRANSFORM_PATTERN = '^.+\\.tsx?$';
|
|
10
10
|
exports.ESM_TS_TRANSFORM_PATTERN = '^.+\\.m?tsx?$';
|
|
11
|
-
exports.TS_JS_TRANSFORM_PATTERN = '
|
|
11
|
+
exports.TS_JS_TRANSFORM_PATTERN = '^.+\\.[tj]sx?$';
|
|
12
12
|
exports.ESM_TS_JS_TRANSFORM_PATTERN = '^.+\\.m?[tj]sx?$';
|
|
13
|
-
exports.JS_TRANSFORM_PATTERN = '
|
|
13
|
+
exports.JS_TRANSFORM_PATTERN = '^.+\\.jsx?$';
|
|
14
14
|
exports.ESM_JS_TRANSFORM_PATTERN = '^.+\\.m?jsx?$';
|
|
15
15
|
// `extensionsToTreatAsEsm` will throw error with `.mjs`
|
|
16
16
|
exports.TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts'];
|
|
@@ -113,12 +113,12 @@ var TsCompiler = /** @class */ (function () {
|
|
|
113
113
|
return importedModulePaths;
|
|
114
114
|
};
|
|
115
115
|
TsCompiler.prototype.fixupCompilerOptionsForModuleKind = function (compilerOptions, isEsm) {
|
|
116
|
-
var _a;
|
|
117
|
-
var moduleResolution = this._ts.ModuleResolutionKind.Node10;
|
|
116
|
+
var _a, _b;
|
|
117
|
+
var moduleResolution = (_a = this._ts.ModuleResolutionKind.Node10) !== null && _a !== void 0 ? _a : this._ts.ModuleResolutionKind.NodeJs;
|
|
118
118
|
if (!isEsm) {
|
|
119
119
|
return __assign(__assign({}, compilerOptions), { module: this._ts.ModuleKind.CommonJS, moduleResolution: moduleResolution });
|
|
120
120
|
}
|
|
121
|
-
var moduleKind = (
|
|
121
|
+
var moduleKind = (_b = compilerOptions.module) !== null && _b !== void 0 ? _b : this._ts.ModuleKind.ESNext;
|
|
122
122
|
var esModuleInterop = compilerOptions.esModuleInterop;
|
|
123
123
|
if ([this._ts.ModuleKind.Node16, this._ts.ModuleKind.NodeNext].includes(moduleKind)) {
|
|
124
124
|
esModuleInterop = true;
|
|
@@ -135,7 +135,7 @@ function createDefaultEsmPreset(tsJestTransformOptions) {
|
|
|
135
135
|
if (tsJestTransformOptions === void 0) { tsJestTransformOptions = {}; }
|
|
136
136
|
logger.debug('creating default ESM Jest preset');
|
|
137
137
|
return {
|
|
138
|
-
extensionsToTreatAsEsm: __spreadArray(
|
|
138
|
+
extensionsToTreatAsEsm: __spreadArray([], __read(constants_1.TS_EXT_TO_TREAT_AS_ESM), false),
|
|
139
139
|
transform: (_a = {},
|
|
140
140
|
_a[constants_1.ESM_TS_TRANSFORM_PATTERN] = [
|
|
141
141
|
'ts-jest',
|
|
@@ -149,7 +149,7 @@ function createDefaultEsmLegacyPreset(tsJestTransformOptions) {
|
|
|
149
149
|
if (tsJestTransformOptions === void 0) { tsJestTransformOptions = {}; }
|
|
150
150
|
logger.debug('creating default ESM Jest preset');
|
|
151
151
|
return {
|
|
152
|
-
extensionsToTreatAsEsm: __spreadArray(
|
|
152
|
+
extensionsToTreatAsEsm: __spreadArray([], __read(constants_1.TS_EXT_TO_TREAT_AS_ESM), false),
|
|
153
153
|
transform: (_a = {},
|
|
154
154
|
_a[constants_1.ESM_TS_TRANSFORM_PATTERN] = [
|
|
155
155
|
'ts-jest/legacy',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "29.2.
|
|
3
|
+
"version": "29.2.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"prebuild": "rimraf dist coverage *.tgz",
|
|
12
12
|
"build": "tsc -p tsconfig.build.json",
|
|
13
13
|
"postbuild": "node scripts/post-build.js",
|
|
14
|
-
"
|
|
15
|
-
"test": "jest",
|
|
14
|
+
"test": "jest -c=jest-src.config.ts",
|
|
15
|
+
"test-e2e-cjs": "jest -c=jest-e2e.config.cjs --no-cache",
|
|
16
|
+
"test-e2e-esm": "node --experimental-vm-modules --no-warnings node_modules/jest/bin/jest.js -c=jest-e2e.config.mjs --no-cache",
|
|
16
17
|
"test-examples": "node scripts/test-examples.js",
|
|
17
18
|
"lint": "eslint --ext .js,.ts .",
|
|
18
19
|
"lint-fix": "eslint --fix --ext .js,.ts .",
|
|
19
|
-
"lint-prettier": "prettier
|
|
20
|
+
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write",
|
|
20
21
|
"lint-prettier-ci": "prettier '**/*.{yml,yaml,md}' --check",
|
|
21
22
|
"doc": "cd website && npm run start",
|
|
22
23
|
"doc:build": "cd website && npm run build",
|
|
@@ -51,15 +52,15 @@
|
|
|
51
52
|
},
|
|
52
53
|
"homepage": "https://kulshekhar.github.io/ts-jest",
|
|
53
54
|
"dependencies": {
|
|
54
|
-
"bs-logger": "0.
|
|
55
|
+
"bs-logger": "^0.2.6",
|
|
55
56
|
"ejs": "^3.1.10",
|
|
56
|
-
"fast-json-stable-stringify": "2.
|
|
57
|
+
"fast-json-stable-stringify": "^2.1.0",
|
|
57
58
|
"jest-util": "^29.0.0",
|
|
58
59
|
"json5": "^2.2.3",
|
|
59
|
-
"lodash.memoize": "4.
|
|
60
|
-
"make-error": "1.
|
|
61
|
-
"semver": "^7.
|
|
62
|
-
"yargs-parser": "^21.
|
|
60
|
+
"lodash.memoize": "^4.1.2",
|
|
61
|
+
"make-error": "^1.3.6",
|
|
62
|
+
"semver": "^7.7.1",
|
|
63
|
+
"yargs-parser": "^21.1.1"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"@babel/core": ">=7.0.0-beta.0 <8",
|
|
@@ -94,47 +95,45 @@
|
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
97
|
"devDependencies": {
|
|
97
|
-
"@commitlint/cli": "18.6.1",
|
|
98
|
-
"@commitlint/config-angular": "18.6.1",
|
|
98
|
+
"@commitlint/cli": "~18.6.1",
|
|
99
|
+
"@commitlint/config-angular": "~18.6.1",
|
|
100
|
+
"@jest/globals": "^29.7.0",
|
|
99
101
|
"@jest/transform": "^29.7.0",
|
|
100
102
|
"@jest/types": "^29.6.3",
|
|
101
|
-
"@types/babel__core": "7.20.5",
|
|
102
|
-
"@types/cross-spawn": "latest",
|
|
103
|
+
"@types/babel__core": "^7.20.5",
|
|
103
104
|
"@types/ejs": "^3.1.5",
|
|
104
|
-
"@types/fs-extra": "
|
|
105
|
-
"@types/
|
|
106
|
-
"@types/
|
|
107
|
-
"@types/lodash.
|
|
108
|
-
"@types/lodash.
|
|
109
|
-
"@types/
|
|
110
|
-
"@types/
|
|
111
|
-
"@types/
|
|
112
|
-
"@types/semver": "
|
|
113
|
-
"@types/yargs": "
|
|
105
|
+
"@types/fs-extra": "^11.0.4",
|
|
106
|
+
"@types/jest": "^29.5.14",
|
|
107
|
+
"@types/js-yaml": "^4.0.9",
|
|
108
|
+
"@types/lodash.camelcase": "^4.3.9",
|
|
109
|
+
"@types/lodash.memoize": "^4.1.9",
|
|
110
|
+
"@types/lodash.set": "^4.3.9",
|
|
111
|
+
"@types/micromatch": "^4.0.9",
|
|
112
|
+
"@types/node": "20.17.19",
|
|
113
|
+
"@types/semver": "^7.5.8",
|
|
114
|
+
"@types/yargs": "^17.0.33",
|
|
114
115
|
"@types/yargs-parser": "21.0.3",
|
|
115
116
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
116
117
|
"@typescript-eslint/parser": "^7.18.0",
|
|
117
118
|
"babel-jest": "^29.7.0",
|
|
118
119
|
"conventional-changelog-cli": "^5.0.0",
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"eslint": "^8.57.0",
|
|
120
|
+
"esbuild": "~0.25.0",
|
|
121
|
+
"eslint": "^8.57.1",
|
|
122
122
|
"eslint-config-prettier": "^9.1.0",
|
|
123
|
-
"eslint-plugin-import": "^2.
|
|
124
|
-
"eslint-plugin-jest": "^28.
|
|
125
|
-
"eslint-plugin-jsdoc": "^48.
|
|
123
|
+
"eslint-plugin-import": "^2.31.0",
|
|
124
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
125
|
+
"eslint-plugin-jsdoc": "^48.11.0",
|
|
126
126
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
127
127
|
"eslint-plugin-prettier": "^4.2.1",
|
|
128
128
|
"execa": "5.1.1",
|
|
129
|
-
"fs-extra": "11.
|
|
129
|
+
"fs-extra": "^11.3.0",
|
|
130
130
|
"glob": "^10.2.6",
|
|
131
|
-
"glob-gitignore": "
|
|
132
|
-
"husky": "4.
|
|
131
|
+
"glob-gitignore": "^1.0.15",
|
|
132
|
+
"husky": "~4.3.8",
|
|
133
133
|
"jest": "^29.7.0",
|
|
134
|
-
"
|
|
135
|
-
"js-yaml": "latest",
|
|
134
|
+
"js-yaml": "^4.1.0",
|
|
136
135
|
"json-schema-to-typescript": "^13.1.2",
|
|
137
|
-
"lint-staged": "
|
|
136
|
+
"lint-staged": "^15.4.3",
|
|
138
137
|
"prettier": "^2.8.8",
|
|
139
138
|
"typescript": "~5.5.4"
|
|
140
139
|
},
|
package/globals.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
const beforeAll: typeof import('@jest/globals').beforeAll
|
|
3
|
-
const beforeEach: typeof import('@jest/globals').beforeEach
|
|
4
|
-
const afterAll: typeof import('@jest/globals').afterAll
|
|
5
|
-
const afterEach: typeof import('@jest/globals').afterEach
|
|
6
|
-
const describe: typeof import('@jest/globals').describe
|
|
7
|
-
const fdescribe: typeof import('@jest/globals').fdescribe
|
|
8
|
-
const xdescribe: typeof import('@jest/globals').xdescribe
|
|
9
|
-
const it: typeof import('@jest/globals').it
|
|
10
|
-
const fit: typeof import('@jest/globals').fit
|
|
11
|
-
const xit: typeof import('@jest/globals').xit
|
|
12
|
-
const test: typeof import('@jest/globals').test
|
|
13
|
-
const xtest: typeof import('@jest/globals').xtest
|
|
14
|
-
const expect: typeof import('@jest/globals').expect
|
|
15
|
-
const jest: typeof import('@jest/globals').jest
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {}
|