https://project.mdnd-it.cc/work_packages/94
This commit is contained in:
2025-08-23 04:25:28 +02:00
parent 725516ad6c
commit 19cfa031d0
25823 changed files with 1095587 additions and 2801760 deletions
+22
View File
@@ -0,0 +1,22 @@
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Copyright Contributors to the Jest project.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+147
View File
@@ -0,0 +1,147 @@
import { CallerTransformOptions, ScriptTransformer, ShouldInstrumentOptions, shouldInstrument } from "@jest/transform";
import { IHasteMap, IModuleMap } from "jest-haste-map";
import Resolver from "jest-resolve";
import { JestEnvironment } from "@jest/environment";
import { expect } from "@jest/globals";
import { SourceMapRegistry } from "@jest/source-map";
import { TestContext, V8CoverageResult } from "@jest/test-result";
import { Config, Global } from "@jest/types";
//#region src/index.d.ts
interface JestGlobals extends Global.TestFrameworkGlobals {
expect: typeof expect;
}
type HasteMapOptions = {
console?: Console;
maxWorkers: number;
resetCache: boolean;
watch?: boolean;
watchman: boolean;
workerThreads?: boolean;
};
interface InternalModuleOptions extends Required<CallerTransformOptions> {
isInternalModule: boolean;
}
declare class Runtime {
private readonly _cacheFS;
private readonly _cacheFSBuffer;
private readonly _config;
private readonly _globalConfig;
private readonly _coverageOptions;
private _currentlyExecutingModulePath;
private readonly _environment;
private readonly _explicitShouldMock;
private readonly _explicitShouldMockModule;
private readonly _onGenerateMock;
private _fakeTimersImplementation;
private readonly _internalModuleRegistry;
private _isCurrentlyExecutingManualMock;
private _mainModule;
private readonly _mockFactories;
private readonly _mockMetaDataCache;
private _mockRegistry;
private _isolatedMockRegistry;
private readonly _moduleMockRegistry;
private readonly _moduleMockFactories;
private readonly _moduleMocker;
private _isolatedModuleRegistry;
private _moduleRegistry;
private readonly _esmoduleRegistry;
private readonly _cjsNamedExports;
private readonly _esmModuleLinkingMap;
private readonly _testPath;
private readonly _resolver;
private _shouldAutoMock;
private readonly _shouldMockModuleCache;
private readonly _shouldUnmockTransitiveDependenciesCache;
private readonly _sourceMapRegistry;
private readonly _scriptTransformer;
private readonly _fileTransforms;
private readonly _fileTransformsMutex;
private _v8CoverageInstrumenter;
private _v8CoverageResult;
private _v8CoverageSources;
private readonly _transitiveShouldMock;
private _unmockList;
private readonly _virtualMocks;
private readonly _virtualModuleMocks;
private _moduleImplementation?;
private readonly jestObjectCaches;
private jestGlobals?;
private readonly esmConditions;
private readonly cjsConditions;
private isTornDown;
private isInsideTestCode;
constructor(config: Config.ProjectConfig, environment: JestEnvironment, resolver: Resolver, transformer: ScriptTransformer, cacheFS: Map<string, string>, coverageOptions: ShouldInstrumentOptions, testPath: string, globalConfig: Config.GlobalConfig);
static shouldInstrument: typeof shouldInstrument;
static createContext(config: Config.ProjectConfig, options: {
console?: Console;
maxWorkers: number;
watch?: boolean;
watchman: boolean;
}): Promise<TestContext>;
static createHasteMap(config: Config.ProjectConfig, options?: HasteMapOptions): Promise<IHasteMap>;
static createResolver(config: Config.ProjectConfig, moduleMap: IModuleMap): Resolver;
unstable_shouldLoadAsEsm(modulePath: string): boolean;
private loadEsmModule;
private resolveModule;
private linkAndEvaluateModule;
unstable_importModule(from: string, moduleName?: string): Promise<unknown | void>;
private loadCjsAsEsm;
private importMock;
private getExportsOfCjs;
requireModule<T = unknown>(from: string, moduleName?: string, options?: InternalModuleOptions, isRequireActual?: boolean): T;
requireInternalModule<T = unknown>(from: string, to?: string): T;
requireActual<T = unknown>(from: string, moduleName: string): T;
requireMock<T = unknown>(from: string, moduleName: string): T;
private _loadModule;
private _getFullTransformationOptions;
requireModuleOrMock<T = unknown>(from: string, moduleName: string): T;
isolateModules(fn: () => void): void;
isolateModulesAsync(fn: () => Promise<void>): Promise<void>;
resetModules(): void;
collectV8Coverage(): Promise<void>;
stopCollectingV8Coverage(): Promise<void>;
getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__'];
getAllV8CoverageInfoCopy(): V8CoverageResult;
getSourceMaps(): SourceMapRegistry;
setMock(from: string, moduleName: string, mockFactory: () => unknown, options?: {
virtual?: boolean;
}): void;
private setModuleMock;
restoreAllMocks(): void;
resetAllMocks(): void;
clearAllMocks(): void;
enterTestCode(): void;
leaveTestCode(): void;
teardown(): void;
private _resolveCjsModule;
private _resolveModule;
private _requireResolve;
private _requireResolvePaths;
private _execModule;
private transformFile;
private transformFileAsync;
private createScriptFromCode;
private _requireCoreModule;
private _importCoreModule;
private _importWasmModule;
private _getMockedNativeModule;
private _generateMock;
private _shouldMockCjs;
private _shouldMockModule;
private _createRequireImplementation;
private _createJestObjectFor;
private _logFormattedReferenceError;
private constructInjectedModuleParameters;
private handleExecutionError;
private getGlobalsForCjs;
private getGlobalsForEsm;
private getGlobalsFromEnvironment;
private readFileBuffer;
private readFile;
setGlobalsForRuntime(globals: JestGlobals): void;
}
//#endregion
export { Runtime as default };
+193
View File
@@ -0,0 +1,193 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {JestEnvironment} from '@jest/environment';
import {expect} from '@jest/globals';
import {SourceMapRegistry} from '@jest/source-map';
import {TestContext, V8CoverageResult} from '@jest/test-result';
import {
CallerTransformOptions,
ScriptTransformer,
ShouldInstrumentOptions,
shouldInstrument,
} from '@jest/transform';
import {Config, Global as Global_2} from '@jest/types';
import {IHasteMap, IModuleMap} from 'jest-haste-map';
import Resolver from 'jest-resolve';
declare type HasteMapOptions = {
console?: Console;
maxWorkers: number;
resetCache: boolean;
watch?: boolean;
watchman: boolean;
workerThreads?: boolean;
};
declare interface InternalModuleOptions
extends Required<CallerTransformOptions> {
isInternalModule: boolean;
}
declare interface JestGlobals extends Global_2.TestFrameworkGlobals {
expect: typeof expect;
}
declare class Runtime {
private readonly _cacheFS;
private readonly _cacheFSBuffer;
private readonly _config;
private readonly _globalConfig;
private readonly _coverageOptions;
private _currentlyExecutingModulePath;
private readonly _environment;
private readonly _explicitShouldMock;
private readonly _explicitShouldMockModule;
private readonly _onGenerateMock;
private _fakeTimersImplementation;
private readonly _internalModuleRegistry;
private _isCurrentlyExecutingManualMock;
private _mainModule;
private readonly _mockFactories;
private readonly _mockMetaDataCache;
private _mockRegistry;
private _isolatedMockRegistry;
private readonly _moduleMockRegistry;
private readonly _moduleMockFactories;
private readonly _moduleMocker;
private _isolatedModuleRegistry;
private _moduleRegistry;
private readonly _esmoduleRegistry;
private readonly _cjsNamedExports;
private readonly _esmModuleLinkingMap;
private readonly _testPath;
private readonly _resolver;
private _shouldAutoMock;
private readonly _shouldMockModuleCache;
private readonly _shouldUnmockTransitiveDependenciesCache;
private readonly _sourceMapRegistry;
private readonly _scriptTransformer;
private readonly _fileTransforms;
private readonly _fileTransformsMutex;
private _v8CoverageInstrumenter;
private _v8CoverageResult;
private _v8CoverageSources;
private readonly _transitiveShouldMock;
private _unmockList;
private readonly _virtualMocks;
private readonly _virtualModuleMocks;
private _moduleImplementation?;
private readonly jestObjectCaches;
private jestGlobals?;
private readonly esmConditions;
private readonly cjsConditions;
private isTornDown;
private isInsideTestCode;
constructor(
config: Config.ProjectConfig,
environment: JestEnvironment,
resolver: Resolver,
transformer: ScriptTransformer,
cacheFS: Map<string, string>,
coverageOptions: ShouldInstrumentOptions,
testPath: string,
globalConfig: Config.GlobalConfig,
);
static shouldInstrument: typeof shouldInstrument;
static createContext(
config: Config.ProjectConfig,
options: {
console?: Console;
maxWorkers: number;
watch?: boolean;
watchman: boolean;
},
): Promise<TestContext>;
static createHasteMap(
config: Config.ProjectConfig,
options?: HasteMapOptions,
): Promise<IHasteMap>;
static createResolver(
config: Config.ProjectConfig,
moduleMap: IModuleMap,
): Resolver;
unstable_shouldLoadAsEsm(modulePath: string): boolean;
private loadEsmModule;
private resolveModule;
private linkAndEvaluateModule;
unstable_importModule(
from: string,
moduleName?: string,
): Promise<unknown | void>;
private loadCjsAsEsm;
private importMock;
private getExportsOfCjs;
requireModule<T = unknown>(
from: string,
moduleName?: string,
options?: InternalModuleOptions,
isRequireActual?: boolean,
): T;
requireInternalModule<T = unknown>(from: string, to?: string): T;
requireActual<T = unknown>(from: string, moduleName: string): T;
requireMock<T = unknown>(from: string, moduleName: string): T;
private _loadModule;
private _getFullTransformationOptions;
requireModuleOrMock<T = unknown>(from: string, moduleName: string): T;
isolateModules(fn: () => void): void;
isolateModulesAsync(fn: () => Promise<void>): Promise<void>;
resetModules(): void;
collectV8Coverage(): Promise<void>;
stopCollectingV8Coverage(): Promise<void>;
getAllCoverageInfoCopy(): JestEnvironment['global']['__coverage__'];
getAllV8CoverageInfoCopy(): V8CoverageResult;
getSourceMaps(): SourceMapRegistry;
setMock(
from: string,
moduleName: string,
mockFactory: () => unknown,
options?: {
virtual?: boolean;
},
): void;
private setModuleMock;
restoreAllMocks(): void;
resetAllMocks(): void;
clearAllMocks(): void;
enterTestCode(): void;
leaveTestCode(): void;
teardown(): void;
private _resolveCjsModule;
private _resolveModule;
private _requireResolve;
private _requireResolvePaths;
private _execModule;
private transformFile;
private transformFileAsync;
private createScriptFromCode;
private _requireCoreModule;
private _importCoreModule;
private _importWasmModule;
private _getMockedNativeModule;
private _generateMock;
private _shouldMockCjs;
private _shouldMockModule;
private _createRequireImplementation;
private _createJestObjectFor;
private _logFormattedReferenceError;
private constructInjectedModuleParameters;
private handleExecutionError;
private getGlobalsForCjs;
private getGlobalsForEsm;
private getGlobalsFromEnvironment;
private readFileBuffer;
private readFile;
setGlobalsForRuntime(globals: JestGlobals): void;
}
export default Runtime;
export {};
File diff suppressed because it is too large Load Diff
+3
View File
@@ -0,0 +1,3 @@
import cjsModule from './index.js';
export default cjsModule.default;
@@ -0,0 +1,14 @@
/**
Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string.
@example
```
import stripBom = require('strip-bom');
stripBom('\uFEFFunicorn');
//=> 'unicorn'
```
*/
declare function stripBom(string: string): string;
export = stripBom;
@@ -0,0 +1,15 @@
'use strict';
module.exports = string => {
if (typeof string !== 'string') {
throw new TypeError(`Expected a string, got ${typeof string}`);
}
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
// conversion translates it to FEFF (UTF-16 BOM)
if (string.charCodeAt(0) === 0xFEFF) {
return string.slice(1);
}
return string;
};
@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
{
"name": "strip-bom",
"version": "4.0.0",
"description": "Strip UTF-8 byte order mark (BOM) from a string",
"license": "MIT",
"repository": "sindresorhus/strip-bom",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"strip",
"bom",
"byte",
"order",
"mark",
"unicode",
"utf8",
"utf-8",
"remove",
"delete",
"trim",
"text",
"string"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
@@ -0,0 +1,54 @@
# strip-bom [![Build Status](https://travis-ci.org/sindresorhus/strip-bom.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-bom)
> Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string
From Wikipedia:
> The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-strip-bom?utm_source=npm-strip-bom&utm_medium=referral&utm_campaign=readme">Get professional support for 'strip-bom' with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---
## Install
```
$ npm install strip-bom
```
## Usage
```js
const stripBom = require('strip-bom');
stripBom('\uFEFFunicorn');
//=> 'unicorn'
```
## Security
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
## Related
- [strip-bom-cli](https://github.com/sindresorhus/strip-bom-cli) - CLI for this module
- [strip-bom-buf](https://github.com/sindresorhus/strip-bom-buf) - Buffer version of this module
- [strip-bom-stream](https://github.com/sindresorhus/strip-bom-stream) - Stream version of this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
+57
View File
@@ -0,0 +1,57 @@
{
"name": "jest-runtime",
"version": "30.0.5",
"repository": {
"type": "git",
"url": "https://github.com/jestjs/jest.git",
"directory": "packages/jest-runtime"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"require": "./build/index.js",
"import": "./build/index.mjs",
"default": "./build/index.js"
},
"./package.json": "./package.json"
},
"dependencies": {
"@jest/environment": "30.0.5",
"@jest/fake-timers": "30.0.5",
"@jest/globals": "30.0.5",
"@jest/source-map": "30.0.1",
"@jest/test-result": "30.0.5",
"@jest/transform": "30.0.5",
"@jest/types": "30.0.5",
"@types/node": "*",
"chalk": "^4.1.2",
"cjs-module-lexer": "^2.1.0",
"collect-v8-coverage": "^1.0.2",
"glob": "^10.3.10",
"graceful-fs": "^4.2.11",
"jest-haste-map": "30.0.5",
"jest-message-util": "30.0.5",
"jest-mock": "30.0.5",
"jest-regex-util": "30.0.1",
"jest-resolve": "30.0.5",
"jest-snapshot": "30.0.5",
"jest-util": "30.0.5",
"slash": "^3.0.0",
"strip-bom": "^4.0.0"
},
"devDependencies": {
"@jest/test-utils": "30.0.5",
"@types/graceful-fs": "^4.1.9",
"jest-environment-node": "30.0.5"
},
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "22236cf58b66039f81893537c90dee290bab427f"
}