ts-jest 26.4.2 → 26.4.4
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 +29 -0
- package/README.md +12 -10
- package/dist/compiler/language-service.js +1 -1
- package/dist/config/config-set.d.ts +4 -2
- package/dist/config/config-set.js +5 -4
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -1
- package/dist/ts-jest-transformer.d.ts +3 -1
- package/dist/ts-jest-transformer.js +47 -44
- package/dist/utils/testing.d.ts +11 -12
- package/package.json +6 -6
package/.ts-jest-digest
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a9a5dc2939780dca25d373663e916519b0ac2dfb
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [26.4.4](https://github.com/kulshekhar/ts-jest/compare/v26.4.3...v26.4.4) (2020-11-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* revert usage of `@jest/create-cache-key-function` ([#2108](https://github.com/kulshekhar/ts-jest/issues/2108)) ([dee8231](https://github.com/kulshekhar/ts-jest/commit/dee823172ce1e8eb9e0b2dd3aeed1ab4033bd0d9)), closes [#2080](https://github.com/kulshekhar/ts-jest/issues/2080) [#2090](https://github.com/kulshekhar/ts-jest/issues/2090) [#2104](https://github.com/kulshekhar/ts-jest/issues/2104)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **testing:** expose all types for util `mocked` ([#2096](https://github.com/kulshekhar/ts-jest/issues/2096)) ([b1d072b](https://github.com/kulshekhar/ts-jest/commit/b1d072b52b9a7665b3a6914b0895f84f6ee3f8c0)), closes [#2086](https://github.com/kulshekhar/ts-jest/issues/2086)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [26.4.3](https://github.com/kulshekhar/ts-jest/compare/v26.4.2...v26.4.3) (2020-10-26)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **compiler:** only exclude test files when initializing compiler ([#2062](https://github.com/kulshekhar/ts-jest/issues/2062)) ([7264c13](https://github.com/kulshekhar/ts-jest/commit/7264c137114b6dd895624e3476dd7ec57b64ee13)), closes [#2061](https://github.com/kulshekhar/ts-jest/issues/2061), [#2068](https://github.com/kulshekhar/ts-jest/issues/2068), [#2072](https://github.com/kulshekhar/ts-jest/issues/2072), [#2073](https://github.com/kulshekhar/ts-jest/issues/2073)
|
|
21
|
+
* **config:** resolve `.babelrc` file path before attempting to read it ([#2071](https://github.com/kulshekhar/ts-jest/issues/2071)) ([681bfef](https://github.com/kulshekhar/ts-jest/commit/681bfef41744f09cd50b71072f4d001cb58da82e)), closes [#2064](https://github.com/kulshekhar/ts-jest/issues/2064)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* **config:** allow to override resolve tsconfig behavior ([#2063](https://github.com/kulshekhar/ts-jest/issues/2063)) ([9f46ace](https://github.com/kulshekhar/ts-jest/commit/9f46acefceb1fa71ee2e8b3b3c172ceb0544b4c4))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
1
30
|
## [26.4.2](https://github.com/kulshekhar/ts-jest/compare/v26.4.1...v26.4.2) (2020-10-23)
|
|
2
31
|
|
|
3
32
|
|
package/README.md
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">ts-jest</h1>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[](https://npmjs.org/package/ts-jest)
|
|
5
|
-
[](https://snyk.io/test/github/kulshekhar/ts-jest)
|
|
6
|
-
[](https://coveralls.io/github/kulshekhar/ts-jest?branch=master)
|
|
7
|
-
[](https://travis-ci.com/kulshekhar/ts-jest)
|
|
8
|
-
[](https://github.com/kulshekhar/ts-jest/actions)
|
|
9
|
-
[](https://github.com/kulshekhar/ts-jest/actions)
|
|
3
|
+
<p align="center">A TypeScript preprocessor with source map support for Jest that lets you use Jest to test projects written in TypeScript.</p>
|
|
10
4
|
|
|
11
|
-
<
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/v/ts-jest/latest.svg?style=flat-square" alt="NPM version" /> </a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/dm/ts-jest.svg?style=flat-square" alt="NPM downloads"/> </a>
|
|
8
|
+
<a href="https://snyk.io/test/github/kulshekhar/ts-jest"><img src="https://snyk.io/test/github/kulshekhar/ts-jest/badge.svg?style=flat-square" alt="Known vulnerabilities"/> </a>
|
|
9
|
+
<a href="https://coveralls.io/github/kulshekhar/ts-jest?branch=master"><img src="https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=master" alt="Coverage status"/> </a>
|
|
10
|
+
<a href="https://travis-ci.com/kulshekhar/ts-jest"><img src="https://travis-ci.com/kulshekhar/ts-jest.svg?branch=master" alt="Build status"/> </a>
|
|
11
|
+
<a href="https://actions-badge.atrox.dev/kulshekhar/ts-jest/goto?ref=master"><img alt="GitHub actions" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fkulshekhar%2Fts-jest%2Fbadge%3Fref%3Dmaster&style=flat-square" /> </a>
|
|
12
|
+
<a href="https://github.com/kulshekhar/ts-jest/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a>
|
|
13
|
+
</p>
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
<img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
|
|
14
16
|
|
|
15
17
|
It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/user/babel7-or-ts).
|
|
16
18
|
|
|
@@ -113,7 +113,7 @@ exports.initializeLanguageServiceInstance = function (configs, logger) {
|
|
|
113
113
|
catch (e) { }
|
|
114
114
|
}
|
|
115
115
|
configs.parsedTsConfig.fileNames
|
|
116
|
-
.filter(function (fileName) { return
|
|
116
|
+
.filter(function (fileName) { return !configs.isTestFile(fileName); })
|
|
117
117
|
.forEach(function (fileName) {
|
|
118
118
|
memoryCache.files.set(fileName, {
|
|
119
119
|
version: 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from '@jest/types';
|
|
2
2
|
import { Logger } from 'bs-logger';
|
|
3
|
-
import { CustomTransformers, Diagnostic, ParsedCommandLine } from 'typescript';
|
|
3
|
+
import { CompilerOptions, CustomTransformers, Diagnostic, ParsedCommandLine } from 'typescript';
|
|
4
4
|
import type { TTypeScript } from '../types';
|
|
5
5
|
export declare class ConfigSet {
|
|
6
6
|
readonly logger: Logger;
|
|
@@ -8,10 +8,12 @@ export declare class ConfigSet {
|
|
|
8
8
|
readonly isolatedModules: boolean;
|
|
9
9
|
readonly cwd: string;
|
|
10
10
|
tsCacheDir: string | undefined;
|
|
11
|
-
parsedTsConfig: ParsedCommandLine
|
|
11
|
+
parsedTsConfig: ParsedCommandLine | Record<string, any>;
|
|
12
12
|
customTransformers: CustomTransformers;
|
|
13
13
|
readonly rootDir: string;
|
|
14
|
+
protected _overriddenCompilerOptions: Partial<CompilerOptions>;
|
|
14
15
|
constructor(jestConfig: Config.ProjectConfig, parentLogger?: Logger | undefined);
|
|
16
|
+
protected _resolveTsConfig(compilerOptions?: CompilerOptions, resolvedConfigFile?: string): Record<string, any>;
|
|
15
17
|
get tsJestDigest(): string;
|
|
16
18
|
get isTestFile(): (fileName: string) => boolean;
|
|
17
19
|
shouldStringifyContent(filePath: string): boolean;
|
|
@@ -169,11 +169,12 @@ var ConfigSet = (function () {
|
|
|
169
169
|
else {
|
|
170
170
|
var baseBabelCfg = { cwd: this.cwd };
|
|
171
171
|
if (typeof options.babelConfig === 'string') {
|
|
172
|
+
var babelCfgPath = this.resolvePath(options.babelConfig);
|
|
172
173
|
if (path_1.extname(options.babelConfig) === '.js') {
|
|
173
|
-
this._babelConfig = __assign(__assign({}, baseBabelCfg), require(
|
|
174
|
+
this._babelConfig = __assign(__assign({}, baseBabelCfg), require(babelCfgPath));
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
|
-
this._babelConfig = __assign(__assign({}, baseBabelCfg), json5.parse(fs_1.readFileSync(
|
|
177
|
+
this._babelConfig = __assign(__assign({}, baseBabelCfg), json5.parse(fs_1.readFileSync(babelCfgPath, 'utf-8')));
|
|
177
178
|
}
|
|
178
179
|
}
|
|
179
180
|
else if (typeof options.babelConfig === 'object') {
|
|
@@ -220,7 +221,7 @@ var ConfigSet = (function () {
|
|
|
220
221
|
}
|
|
221
222
|
var tsconfigOpt = (_c = options.tsConfig) !== null && _c !== void 0 ? _c : options.tsconfig;
|
|
222
223
|
var configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined;
|
|
223
|
-
this.parsedTsConfig = this.
|
|
224
|
+
this.parsedTsConfig = this._resolveTsConfig(typeof tsconfigOpt === 'object' ? tsconfigOpt : undefined, configFilePath);
|
|
224
225
|
this.raiseDiagnostics(this.parsedTsConfig.errors, configFilePath);
|
|
225
226
|
this.logger.debug({ tsconfig: this.parsedTsConfig }, 'normalized typescript config via ts-jest option');
|
|
226
227
|
var astTransformers = options.astTransformers;
|
|
@@ -290,7 +291,7 @@ var ConfigSet = (function () {
|
|
|
290
291
|
this.logger.debug({ cacheDirectory: res }, 'will use file caching');
|
|
291
292
|
this.tsCacheDir = res;
|
|
292
293
|
};
|
|
293
|
-
ConfigSet.prototype.
|
|
294
|
+
ConfigSet.prototype._resolveTsConfig = function (compilerOptions, resolvedConfigFile) {
|
|
294
295
|
var e_2, _a;
|
|
295
296
|
var _b;
|
|
296
297
|
var config = { compilerOptions: Object.create(null) };
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_JEST_TEST_MATCH = exports.JS_JSX_REGEX = exports.TS_TSX_REGEX = exports.LINE_FEED = void 0;
|
|
3
|
+
exports.DEFAULT_JEST_TEST_MATCH = exports.DECLARATION_TYPE_EXT = exports.JS_JSX_REGEX = exports.TS_TSX_REGEX = exports.LINE_FEED = void 0;
|
|
4
4
|
exports.LINE_FEED = '\n';
|
|
5
5
|
exports.TS_TSX_REGEX = /\.tsx?$/;
|
|
6
6
|
exports.JS_JSX_REGEX = /\.jsx?$/;
|
|
7
|
+
exports.DECLARATION_TYPE_EXT = '.d.ts';
|
|
7
8
|
exports.DEFAULT_JEST_TEST_MATCH = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { CacheKeyOptions, TransformedSource, Transformer, TransformOptions } from '@jest/transform';
|
|
2
2
|
import type { Config } from '@jest/types';
|
|
3
3
|
import type { Logger } from 'bs-logger';
|
|
4
|
+
import { ConfigSet } from './config/config-set';
|
|
4
5
|
export declare class TsJestTransformer implements Transformer {
|
|
5
6
|
protected readonly logger: Logger;
|
|
7
|
+
protected _transformCfgStr: string;
|
|
6
8
|
constructor();
|
|
9
|
+
configsFor(jestConfig: Config.ProjectConfig): ConfigSet;
|
|
7
10
|
process(input: string, filePath: Config.Path, jestConfig: Config.ProjectConfig, transformOptions?: TransformOptions): TransformedSource | string;
|
|
8
11
|
getCacheKey(fileContent: string, filePath: string, _jestConfigStr: string, transformOptions: CacheKeyOptions): string;
|
|
9
|
-
protected createOrResolveTransformerCfg(jestConfig: Config.ProjectConfig): void;
|
|
10
12
|
}
|
|
@@ -10,31 +10,65 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
14
|
exports.TsJestTransformer = void 0;
|
|
18
|
-
var create_cache_key_function_1 = __importDefault(require("@jest/create-cache-key-function"));
|
|
19
15
|
var config_set_1 = require("./config/config-set");
|
|
20
16
|
var constants_1 = require("./constants");
|
|
21
17
|
var json_1 = require("./utils/json");
|
|
22
18
|
var jsonable_value_1 = require("./utils/jsonable-value");
|
|
23
19
|
var logger_1 = require("./utils/logger");
|
|
24
20
|
var messages_1 = require("./utils/messages");
|
|
21
|
+
var sha1_1 = require("./utils/sha1");
|
|
25
22
|
var TsJestTransformer = (function () {
|
|
26
23
|
function TsJestTransformer() {
|
|
27
24
|
this.logger = logger_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
|
28
25
|
this.logger.debug('created new transformer');
|
|
29
26
|
}
|
|
27
|
+
TsJestTransformer.prototype.configsFor = function (jestConfig) {
|
|
28
|
+
var ccs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.value === jestConfig; });
|
|
29
|
+
var configSet;
|
|
30
|
+
if (ccs) {
|
|
31
|
+
this._transformCfgStr = ccs.transformerCfgStr;
|
|
32
|
+
configSet = ccs.configSet;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
var serializedJestCfg_1 = json_1.stringify(jestConfig);
|
|
36
|
+
var serializedCcs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.serialized === serializedJestCfg_1; });
|
|
37
|
+
if (serializedCcs) {
|
|
38
|
+
serializedCcs.jestConfig.value = jestConfig;
|
|
39
|
+
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
|
40
|
+
configSet = serializedCcs.configSet;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.logger.info('no matching config-set found, creating a new one');
|
|
44
|
+
configSet = new config_set_1.ConfigSet(jestConfig);
|
|
45
|
+
var jest_1 = __assign({}, jestConfig);
|
|
46
|
+
var globals = (jest_1.globals = __assign({}, jest_1.globals));
|
|
47
|
+
jest_1.name = undefined;
|
|
48
|
+
jest_1.cacheDirectory = undefined;
|
|
49
|
+
delete globals['ts-jest'];
|
|
50
|
+
this._transformCfgStr = new jsonable_value_1.JsonableValue(__assign(__assign({ digest: configSet.tsJestDigest, babel: configSet.babelConfig }, jest_1), { tsconfig: {
|
|
51
|
+
options: configSet.parsedTsConfig.options,
|
|
52
|
+
raw: configSet.parsedTsConfig.raw,
|
|
53
|
+
} })).serialized;
|
|
54
|
+
TsJestTransformer._cachedConfigSets.push({
|
|
55
|
+
jestConfig: new jsonable_value_1.JsonableValue(jestConfig),
|
|
56
|
+
configSet: configSet,
|
|
57
|
+
transformerCfgStr: this._transformCfgStr,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return configSet;
|
|
62
|
+
};
|
|
30
63
|
TsJestTransformer.prototype.process = function (input, filePath, jestConfig, transformOptions) {
|
|
31
64
|
this.logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'processing', filePath);
|
|
32
65
|
var result;
|
|
33
66
|
var source = input;
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
67
|
+
var configs = this.configsFor(jestConfig);
|
|
68
|
+
var hooks = configs.hooks;
|
|
69
|
+
var shouldStringifyContent = configs.shouldStringifyContent(filePath);
|
|
70
|
+
var babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
|
71
|
+
var isDefinitionFile = filePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
|
|
38
72
|
var isJsFile = constants_1.JS_JSX_REGEX.test(filePath);
|
|
39
73
|
var isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(filePath);
|
|
40
74
|
if (shouldStringifyContent) {
|
|
@@ -43,12 +77,12 @@ var TsJestTransformer = (function () {
|
|
|
43
77
|
else if (isDefinitionFile) {
|
|
44
78
|
result = '';
|
|
45
79
|
}
|
|
46
|
-
else if (!
|
|
80
|
+
else if (!configs.parsedTsConfig.options.allowJs && isJsFile) {
|
|
47
81
|
this.logger.warn({ fileName: filePath }, messages_1.interpolate("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", { path: filePath }));
|
|
48
82
|
result = source;
|
|
49
83
|
}
|
|
50
84
|
else if (isJsFile || isTsFile) {
|
|
51
|
-
result =
|
|
85
|
+
result = configs.tsCompiler.compile(source, filePath);
|
|
52
86
|
}
|
|
53
87
|
else {
|
|
54
88
|
var message = babelJest ? "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." : "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.";
|
|
@@ -69,41 +103,10 @@ var TsJestTransformer = (function () {
|
|
|
69
103
|
return result;
|
|
70
104
|
};
|
|
71
105
|
TsJestTransformer.prototype.getCacheKey = function (fileContent, filePath, _jestConfigStr, transformOptions) {
|
|
72
|
-
this.
|
|
106
|
+
var configs = this.configsFor(transformOptions.config);
|
|
73
107
|
this.logger.debug({ fileName: filePath, transformOptions: transformOptions }, 'computing cache key for', filePath);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
instrument: false,
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
TsJestTransformer.prototype.createOrResolveTransformerCfg = function (jestConfig) {
|
|
80
|
-
var ccs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.value === jestConfig; });
|
|
81
|
-
if (ccs) {
|
|
82
|
-
this._transformCfgStr = ccs.transformerCfgStr;
|
|
83
|
-
this._tsJestCfgSet = ccs.configSet;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
var serializedJestCfg_1 = json_1.stringify(jestConfig);
|
|
87
|
-
var serializedCcs = TsJestTransformer._cachedConfigSets.find(function (cs) { return cs.jestConfig.serialized === serializedJestCfg_1; });
|
|
88
|
-
if (serializedCcs) {
|
|
89
|
-
serializedCcs.jestConfig.value = jestConfig;
|
|
90
|
-
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
|
91
|
-
this._tsJestCfgSet = serializedCcs.configSet;
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.logger.info('no matching config-set found, creating a new one');
|
|
95
|
-
this._tsJestCfgSet = new config_set_1.ConfigSet(jestConfig);
|
|
96
|
-
this._transformCfgStr = new jsonable_value_1.JsonableValue(__assign(__assign({ digest: this._tsJestCfgSet.tsJestDigest, babel: this._tsJestCfgSet.babelConfig }, jestConfig), { tsconfig: {
|
|
97
|
-
options: this._tsJestCfgSet.parsedTsConfig.options,
|
|
98
|
-
raw: this._tsJestCfgSet.parsedTsConfig.raw,
|
|
99
|
-
} })).serialized;
|
|
100
|
-
TsJestTransformer._cachedConfigSets.push({
|
|
101
|
-
jestConfig: new jsonable_value_1.JsonableValue(jestConfig),
|
|
102
|
-
configSet: this._tsJestCfgSet,
|
|
103
|
-
transformerCfgStr: this._transformCfgStr,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
108
|
+
var _a = transformOptions.instrument, instrument = _a === void 0 ? false : _a, _b = transformOptions.rootDir, rootDir = _b === void 0 ? configs.rootDir : _b;
|
|
109
|
+
return sha1_1.sha1(this._transformCfgStr, '\x00', rootDir, '\x00', "instrument:" + (instrument ? 'on' : 'off'), '\x00', fileContent, '\x00', filePath);
|
|
107
110
|
};
|
|
108
111
|
TsJestTransformer._cachedConfigSets = [];
|
|
109
112
|
return TsJestTransformer;
|
package/dist/utils/testing.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
declare type MockableFunction = (...args: any[]) => any;
|
|
3
|
-
declare type MethodKeysOf<T> = {
|
|
2
|
+
export declare type MockableFunction = (...args: any[]) => any;
|
|
3
|
+
export declare type MethodKeysOf<T> = {
|
|
4
4
|
[K in keyof T]: T[K] extends MockableFunction ? K : never;
|
|
5
5
|
}[keyof T];
|
|
6
|
-
declare type PropertyKeysOf<T> = {
|
|
6
|
+
export declare type PropertyKeysOf<T> = {
|
|
7
7
|
[K in keyof T]: T[K] extends MockableFunction ? never : K;
|
|
8
8
|
}[keyof T];
|
|
9
|
-
declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
|
|
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>> {
|
|
9
|
+
export declare type ArgumentsOf<T> = T extends (...args: infer A) => any ? A : never;
|
|
10
|
+
export declare type ConstructorArgumentsOf<T> = T extends new (...args: infer A) => any ? A : never;
|
|
11
|
+
export interface MockWithArgs<T extends MockableFunction> extends jest.MockInstance<ReturnType<T>, ArgumentsOf<T>> {
|
|
12
12
|
new (...args: ConstructorArgumentsOf<T>): T;
|
|
13
13
|
(...args: ArgumentsOf<T>): ReturnType<T>;
|
|
14
14
|
}
|
|
15
|
-
declare type MaybeMockedConstructor<T> = T extends new (...args: any[]) => infer R ? jest.MockInstance<R, ConstructorArgumentsOf<T>> : T;
|
|
16
|
-
declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
|
|
15
|
+
export declare type MaybeMockedConstructor<T> = T extends new (...args: any[]) => infer R ? jest.MockInstance<R, ConstructorArgumentsOf<T>> : T;
|
|
16
|
+
export declare type MockedFunction<T extends MockableFunction> = MockWithArgs<T> & {
|
|
17
17
|
[K in keyof T]: T[K];
|
|
18
18
|
};
|
|
19
|
-
declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
20
|
-
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
19
|
+
export declare type MockedFunctionDeep<T extends MockableFunction> = MockWithArgs<T> & MockedObjectDeep<T>;
|
|
20
|
+
export declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
21
21
|
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunction<T[K]> : T[K];
|
|
22
22
|
} & {
|
|
23
23
|
[K in PropertyKeysOf<T>]: T[K];
|
|
24
24
|
};
|
|
25
|
-
declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
25
|
+
export declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
26
26
|
[K in MethodKeysOf<T>]: T[K] extends MockableFunction ? MockedFunctionDeep<T[K]> : T[K];
|
|
27
27
|
} & {
|
|
28
28
|
[K in PropertyKeysOf<T>]: MaybeMockedDeep<T[K]>;
|
|
@@ -31,4 +31,3 @@ export declare type MaybeMockedDeep<T> = T extends MockableFunction ? MockedFunc
|
|
|
31
31
|
export declare type MaybeMocked<T> = T extends MockableFunction ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
32
32
|
export declare function mocked<T>(item: T, deep?: false): MaybeMocked<T>;
|
|
33
33
|
export declare function mocked<T>(item: T, deep: true): MaybeMockedDeep<T>;
|
|
34
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-jest",
|
|
3
|
-
"version": "26.4.
|
|
3
|
+
"version": "26.4.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
|
-
"bin":
|
|
6
|
+
"bin": {
|
|
7
|
+
"ts-jest": "cli.js"
|
|
8
|
+
},
|
|
7
9
|
"description": "A preprocessor with source maps support to help use TypeScript with Jest",
|
|
8
10
|
"scripts": {
|
|
9
11
|
"prebuild": "node scripts/clean-dist.js",
|
|
10
12
|
"build": "tsc -p tsconfig.build.json",
|
|
11
13
|
"postbuild": "node scripts/post-build.js",
|
|
12
14
|
"clean": "node scripts/clean.js",
|
|
13
|
-
"pretest": "npm run lint",
|
|
14
15
|
"test": "run-s -s test:e2e \"test:unit -- {@}\" --",
|
|
15
16
|
"test:prepare": "npm run test:e2e -- --prepareOnly",
|
|
16
17
|
"test:e2e": "node scripts/e2e.js",
|
|
@@ -56,7 +57,6 @@
|
|
|
56
57
|
},
|
|
57
58
|
"homepage": "https://kulshekhar.github.io/ts-jest",
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@jest/create-cache-key-function": "^26.5.0",
|
|
60
60
|
"@types/jest": "26.x",
|
|
61
61
|
"bs-logger": "0.x",
|
|
62
62
|
"buffer-from": "1.x",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@commitlint/cli": "11.x",
|
|
85
|
-
"@commitlint/config-
|
|
85
|
+
"@commitlint/config-angular": "^11.0.0",
|
|
86
86
|
"@jest/transform": "26.x",
|
|
87
87
|
"@jest/types": "26.x",
|
|
88
88
|
"@types/babel__core": "7.x",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@types/lodash.set": "4.x",
|
|
97
97
|
"@types/micromatch": "4.x",
|
|
98
98
|
"@types/mkdirp": "latest",
|
|
99
|
-
"@types/node": "
|
|
99
|
+
"@types/node": "14.x",
|
|
100
100
|
"@types/react": "16.x",
|
|
101
101
|
"@types/semver": "latest",
|
|
102
102
|
"@types/yargs": "latest",
|