Socket
Socket
Sign inDemoInstall

ts-jest

Package Overview
Dependencies
314
Maintainers
3
Versions
190
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 29.1.1 to 29.1.2

4

dist/legacy/config/config-set.d.ts
import { Logger } from 'bs-logger';
import type * as ts from 'typescript';
import type { RawCompilerOptions } from '../../raw-compiler-options';
import type { ProjectConfigTsJest, TsJestAstTransformer, TTypeScript } from '../../types';
import type { TsJestAstTransformer, TsJestTransformOptions, TTypeScript } from '../../types';
export declare class ConfigSet {

@@ -21,3 +21,3 @@ readonly parentLogger?: Logger | undefined;

useESM: boolean;
constructor(jestConfig: ProjectConfigTsJest | undefined, parentLogger?: Logger | undefined);
constructor(jestConfig: TsJestTransformOptions['config'] | undefined, parentLogger?: Logger | undefined);
/**

@@ -24,0 +24,0 @@ * Load TypeScript configuration. Returns the parsed TypeScript config and any `tsconfig` options specified in ts-jest

import type { SyncTransformer, TransformedSource } from '@jest/transform';
import type { CompilerInstance, ProjectConfigTsJest, TransformOptionsTsJest, TsJestGlobalOptions } from '../types';
import type { CompilerInstance, TsJestTransformerOptions, TsJestTransformOptions } from '../types';
import { ConfigSet } from './config/config-set';
export declare class TsJestTransformer implements SyncTransformer {
export declare class TsJestTransformer implements SyncTransformer<TsJestTransformerOptions> {
private readonly tsJestConfig?;

@@ -12,5 +12,5 @@ private readonly _logger;

private _watchMode;
constructor(tsJestConfig?: TsJestGlobalOptions | undefined);
constructor(tsJestConfig?: import("../types").TsJestGlobalOptions | undefined);
private _configsFor;
protected _createConfigSet(config: ProjectConfigTsJest | undefined): ConfigSet;
protected _createConfigSet(config: TsJestTransformOptions['config'] | undefined): ConfigSet;
protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;

@@ -20,4 +20,4 @@ /**

*/
process(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): TransformedSource;
processAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<TransformedSource>;
process(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): TransformedSource;
processAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<TransformedSource>;
private processWithTs;

@@ -32,4 +32,4 @@ private runTsJestHook;

*/
getCacheKey(fileContent: string, filePath: string, transformOptions: TransformOptionsTsJest): string;
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TransformOptionsTsJest): Promise<string>;
getCacheKey(fileContent: string, filePath: string, transformOptions: TsJestTransformOptions): string;
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<string>;
/**

@@ -36,0 +36,0 @@ * Subclasses extends `TsJestTransformer` can call this method to get resolved module disk cache

@@ -199,36 +199,30 @@ "use strict";

TsJestTransformer.prototype.processAsync = function (sourceText, sourcePath, transformOptions) {
var _a;
return __awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
configs = this._configsFor(transformOptions);
shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
result = {
code: processWithTsResult.code,
};
if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
reject(configs.createTsError(processWithTsResult.diagnostics));
}
if (!babelJest) return [3 /*break*/, 2];
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
case 1:
// do not instrument here, jest will do it anyway afterwards
result = _b.sent();
_b.label = 2;
case 2:
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
resolve(result);
return [2 /*return*/];
}
});
}); })];
var configs, shouldStringifyContent, babelJest, result, processWithTsResult;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
this._logger.debug({ fileName: sourcePath, transformOptions: transformOptions }, 'processing', sourcePath);
configs = this._configsFor(transformOptions);
shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
result = {
code: processWithTsResult.code,
};
if ((_a = processWithTsResult.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
throw configs.createTsError(processWithTsResult.diagnostics);
}
if (!babelJest) return [3 /*break*/, 2];
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
return [4 /*yield*/, babelJest.processAsync(result.code, sourcePath, __assign(__assign({}, transformOptions), { instrument: false }))];
case 1:
// do not instrument here, jest will do it anyway afterwards
result = _b.sent();
_b.label = 2;
case 2:
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
return [2 /*return*/, result];
}
});

@@ -315,3 +309,3 @@ });

// we do not instrument, ensure it is false all the time
var instrument = (_a = transformOptions.instrument, _a === void 0 ? false : _a);
var supportsStaticESM = transformOptions.supportsStaticESM, instrument = (_a = transformOptions.instrument, _a === void 0 ? false : _a);
var constructingCacheKeyElements = [

@@ -324,2 +318,4 @@ this._transformCfgStr,

exports.CACHE_KEY_EL_SEPARATOR,
"supportsStaticESM:".concat(supportsStaticESM ? 'on' : 'off'),
exports.CACHE_KEY_EL_SEPARATOR,
fileContent,

@@ -326,0 +322,0 @@ exports.CACHE_KEY_EL_SEPARATOR,

@@ -128,4 +128,4 @@ import type { TransformedSource, TransformOptions } from '@jest/transform';

*/
export interface TransformOptionsTsJest extends TransformOptions {
config: ProjectConfigTsJest;
export interface TransformOptionsTsJest<TransformerConfig = unknown> extends TransformOptions<TransformerConfig> {
config: Config.ProjectConfig;
}

@@ -146,2 +146,3 @@ /**

export type TsJestTransformerOptions = TsJestGlobalOptions;
export type TsJestTransformOptions = TransformOptions<TsJestTransformerOptions>;
export interface JestConfigWithTsJest extends Omit<Config.InitialOptions, 'transform'> {

@@ -148,0 +149,0 @@ transform?: {

{
"name": "ts-jest",
"version": "29.1.1",
"version": "29.1.2",
"main": "dist/index.js",

@@ -131,7 +131,7 @@ "types": "dist/index.d.ts",

"js-yaml": "latest",
"json-schema-to-typescript": "^13.0.1",
"json-schema-to-typescript": "^13.0.2",
"lint-staged": "latest",
"lodash.camelcase": "^4.3.0",
"lodash.set": "^4.3.2",
"node-fetch": "^3.3.1",
"node-fetch": "^3.3.2",
"prettier": "^2.8.8",

@@ -147,4 +147,4 @@ "typescript": "~5.1.3"

"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
"node": "^16.10.0 || ^18.0.0 || >=20.0.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc