jest-metadata
Version:
🦸♂️ Superhero power for your Jest reporters! 🦸♀️
23 lines (22 loc) • 1.14 kB
TypeScript
import type { ProcessRealm } from './ProcessRealm';
export declare function isServer(): boolean;
export declare function isClient(): boolean;
export declare function registerServerId(id: string): void;
export declare function isJestWorker(): boolean;
export declare function injectRealmIntoSandbox(sandbox: any, realm: ProcessRealm): ProcessRealm;
/**
* Workaround for the fallback mode, when Jest uses jest-environment-node.
* Jest blindly copies `globalThis` into the sandbox, so it is not enough to
* simply check that __JEST_METADATA_SANDBOX__ is not truthy.
*
* This is especially bad in Jest's single worker mode, because
* reporter's globalThis === testEnvironment's globalThis == sandbox.
*
* This hook is enabled after the copying happens, and disabled at later stages
* when all potentially conflicting packages are loaded. It is not easy to
* grasp, but it works.
*/
export declare function detectDuplicateRealms(enabled: boolean): void;
export declare function getSandboxedRealm(): ProcessRealm | undefined;
export declare function getServerId(): string | undefined;
export declare function getClientId(): string;