@remotex-labs/xjet 1.3.2 → 1.3.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/modules/shared/components/require.component.ts", "../src/modules/shared/shared.module.ts", "../src/modules/shared/states/mock.state.ts", "../src/modules/symlinks/services/inject.service.ts", "../src/modules/shared/services/emit.service.ts", "../src/modules/packets/packets.module.ts", "../src/modules/packets/schema/packet.schema.ts", "../src/modules/packets/constants/packet-schema.constants.ts", "../src/modules/messages/constants/report.constant.ts", "../src/modules/shared/models/describe.model.ts", "../src/modules/shared/errors/execution.error.ts", "../src/modules/shared/states/suite.state.ts", "../src/modules/shared/components/log.component.ts", "../src/components/location.component.ts", "../src/modules/shared/components/object.component.ts", "../src/modules/shared/mock/fn.mock.ts", "../src/modules/shared/mock/spy.mock.ts", "../src/modules/shared/services/timer.service.ts", "../src/modules/shared/components/printf.component.ts", "../src/modules/shared/directives/each.directive.ts", "../src/errors/timeout.error.ts", "../src/components/timeout.component.ts", "../src/modules/shared/errors/failing.error.ts", "../src/modules/shared/models/test.model.ts", "../src/modules/shared/directives/test.directive.ts", "../src/modules/shared/directives/describe.directive.ts", "../src/modules/shared/models/hook.model.ts", "../src/modules/shared/directives/hook.directive.ts"],
4
- "sourceRoot": "https://github.com/remotex-lab/xJet/tree/v1.3.2/",
5
- "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { Module } from 'module';\n\n/**\n * Module interception utility that enhances Node.js requires {@link NodeJS.Require} functionality to enable mocking.\n *\n * @remarks\n * This module replaces the global `require` function with an enhanced version that:\n * - Logs all module import operations for debugging\n * - Creates shallow copies of object exports to enable property overriding\n * - Maintains original function references for direct function exports\n * - Provides a foundation for runtime module mocking and testing\n *\n * The primary purpose is to make modules mockable by ensuring that object exports\n * can be modified without affecting the original cached module, enabling test doubles\n * and dependency injection in testing environments.\n *\n * Responsibilities:\n * - Module loading tracking\n * - Export transformation for mockability\n * - Cache management\n * - Internal module protection\n *\n * @example\n * ```ts\n * // Import this module at the entry point before any other imports\n * import './require-interceptor';\n *\n * // Now you can mock modules by overriding properties\n * const fs = require('fs');\n * fs.readFileSync = jest.fn().mockReturnValue('mocked content');\n *\n * // Or you can mock getter-based modules like esbuild\n * const esbuild = require('esbuild');\n * Object.defineProperty(esbuild, 'build', {\n * get: () => jest.fn().mockResolvedValue({ errors: [], warnings: [] })\n * });\n * ```\n *\n * @see Module\n * @see NodeJS.Require\n *\n * @since 1.2.2\n */\n\nif(require) {\n const original = require;\n\n /**\n * Enhanced requires function that wraps the original Node.js `require` to enable mocking.\n *\n * @param moduleName - The name or path of the module to require\n * @returns The exports from the required module, possibly transformed for mockability\n *\n * @remarks\n * This function intercepts all `require` calls and transforms module exports to make them\n * mockable:\n *\n * - Function exports are returned directly (can be mocked via function replacement)\n * - Object exports are shallow-cloned to enable property overriding without affecting the cache\n * - Modules with getter properties (like esbuild) can be mocked by redefining property descriptors\n * - Primitive exports are passed through unchanged\n *\n * The transformation creates a layer of indirection that allows tests to replace\n * or modify functionality without permanently altering the module cache.\n *\n * @since 1.2.2\n */\n\n const fn = (moduleName: string): unknown => {\n const resolvedPath = original.resolve(moduleName);\n const exports = original(moduleName);\n const resolved = original.cache[resolvedPath] as (Module & { internal?: boolean }) | undefined;\n if (!resolved || resolved.internal) return exports;\n\n let result: unknown;\n if (typeof resolved.exports === 'function') {\n result = resolved.exports;\n } else if (typeof resolved.exports === 'object' && resolved.exports !== null) {\n result = { ...resolved.exports };\n } else {\n result = resolved.exports;\n }\n\n resolved.exports = result;\n resolved.internal = true;\n\n return result;\n };\n\n Object.assign(fn, original);\n globalThis.require = fn as typeof require;\n}\n", "/**\n * Imports\n */\n\nimport '@shared/components/require.component';\nimport { xExpect } from '@remotex-labs/xjet-expect';\nimport { MockState } from '@shared/states/mock.state';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport * as logging from '@shared/components/log.component';\nimport { spyOnImplementation } from '@shared/mock/spy.mock';\nimport * as FakeTimer from '@shared/services/timer.service';\nimport { TestDirective } from '@shared/directives/test.directive';\nimport { DescribeDirective } from '@shared/directives/describe.directive';\nimport { fnImplementation, mockImplementation } from '@shared/mock/fn.mock';\nimport { afterAllDirective, afterEachDirective } from '@shared/directives/hook.directive';\nimport { beforeAllDirective, beforeEachDirective } from '@shared/directives/hook.directive';\n\n/**\n * Clears the specified mock method on all registered mocks\n *\n * @param method - The method name to clear on all mock instances\n *\n * @throws TypeError - When called with an invalid method name\n *\n * @remarks\n * This utility function iterates through all mocks registered in the MockState\n * and calls the specified method on each one, effectively performing a batch operation\n * across all mock instances.\n *\n * @example\n * ```ts\n * // Clear all recorded calls on all mocks\n * clearMocks('resetHistory');\n *\n * // Reset behavior on all mocks\n * clearMocks('resetBehavior');\n * ```\n *\n * @see MockState\n *\n * @since 1.0.0\n */\n\nfunction clearMocks(method: keyof MockState): void {\n MockState.mocks.forEach((mock) => {\n const instance = mock.deref();\n if(!instance) {\n return MockState.mocks.delete(mock);\n }\n\n instance[method]();\n });\n}\n\n/**\n * Set global\n */\n\nconst setupGlobals = (): void => {\n const globals = globalThis as { [key: string]: unknown; };\n\n globals.xJet = {\n /**\n * Mock\n */\n\n fn: fnImplementation,\n mock: mockImplementation,\n spyOn: spyOnImplementation,\n clearAllMocks: (): void => clearMocks('mockClear'),\n resetAllMocks: (): void => clearMocks('mockReset'),\n restoreAllMocks: (): void => clearMocks('mockRestore'),\n\n /**\n * Logs\n */\n\n log: logging.log,\n info: logging.info,\n warn: logging.warn,\n error: logging.error,\n debug: logging.debug,\n\n /**\n * Timers\n */\n\n runAllTimers: FakeTimer.runAllTimers,\n useFakeTimers: FakeTimer.useFakeTimers,\n useRealTimers: FakeTimer.useRealTimers,\n clearAllTimers: FakeTimer.clearAllTimers,\n runAllTimersAsync: FakeTimer.runAllTimersAsync,\n advanceTimersByTime: FakeTimer.advanceTimersByTime,\n runOnlyPendingTimers: FakeTimer.runOnlyPendingTimers,\n runOnlyPendingTimersAsync: FakeTimer.runOnlyPendingTimersAsync\n };\n\n globals.expect = xExpect;\n globals.state = inject(SuiteState);\n globals.it = TestDirective.getInstance();\n globals.test = TestDirective.getInstance();\n globals.describe = DescribeDirective.getInstance();\n globals.afterAll = afterAllDirective;\n globals.beforeAll = beforeAllDirective;\n globals.afterEach = afterEachDirective;\n globals.beforeEach = beforeEachDirective;\n};\n\nsetupGlobals();\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { PromiseValueType } from '@shared/states/interfaces/mock-state.interface';\nimport type { BoundInterface } from '@shared/components/interfaces/polyfill-component.interface';\nimport type { MockInvocationResultInterface } from '@shared/states/interfaces/mock-state.interface';\nimport type { ImplementationType, MocksStateInterface } from '@shared/states/interfaces/mock-state.interface';\n\n/**\n * @template DEFAULT_MOCK_NAME\n * A constant that holds the default name used for mocking purposes.\n * It is commonly used in testing scenarios to provide a standard mock identifier.\n *\n * @remarks\n * The value of `DEFAULT_MOCK_NAME` is set to 'xJet.mock()'. It is recommended\n * to use this variable as the default name to maintain consistency across\n * mock-related functionalities in your application.\n *\n * @since 1.0.0\n */\n\nconst DEFAULT_MOCK_NAME = 'xJet.mock()';\n\n/**\n * A powerful mock state manager for simulating functions and classes in tests.\n *\n * @template F - The function signature being mocked, defaults to any function\n *\n * @remarks\n * MockState provides a complete mocking solution. It tracks\n * all invocations, including arguments, return values, and contexts, while also allowing\n * customization of behavior through various methods like `mockImplementation` and\n * `mockReturnValue`.\n *\n * Key features:\n * - Tracks call arguments, return values, and execution contexts\n * - Supports one-time implementations and return values\n * - Manages Promise resolutions and rejections\n * - Provides methods for resetting or restoring mock state\n * - Preserves the interface of the original function\n *\n * @example\n * ```ts\n * // Create a basic mock\n * const mockFn = new MockState();\n *\n * // Configure return values\n * mockFn.mockReturnValue('default');\n * mockFn.mockReturnValueOnce('first call');\n *\n * // Use the mock\n * console.log(mockFn()); // 'first call'\n * console.log(mockFn()); // 'default'\n *\n * // Inspect calls\n * console.log(mockFn.mock.calls); // [[], []]\n * ```\n *\n * @since 1.0.0\n */\n\nexport class MockState<F extends FunctionType = FunctionType> extends Function {\n /**\n * List of all mocks that created as WeakRef\n */\n\n static mocks: Set<WeakRef<MockState>> = new Set();\n\n /**\n * The `name` property represents the name of the mock function.\n */\n\n override name: string;\n\n /**\n * Flag to detect mock functions\n */\n\n readonly xJetMock: boolean = true;\n\n /**\n * Holds the current state of the mock, including all invocation records.\n *\n * @remarks\n * This property tracks the complete history of the mock's usage, storing\n * information like call arguments, return values, execution contexts,\n * instances, and the order of invocations.\n *\n * It's initialized with empty arrays for tracking and gets updated with\n * each invocation. This state is what powers the inspection capabilities\n * accessible via the public `mock` getter.\n *\n * @since 1.0.0\n */\n\n private state: MocksStateInterface<F>;\n\n /**\n * Stores one-time implementations to be used on successive invocations.\n *\n * @remarks\n * This queue contains functions that will be consumed in FIFO order\n * (first-in, first-out) when the mock is called. Each implementation\n * is used exactly once and then removed from the queue.\n *\n * When adding implementations with `mockImplementationOnce()` or similar\n * methods, they are pushed to this queue. On invocation, the mock will\n * check this queue first, using and removing the oldest implementation\n * if available, or falling back to the default implementation.\n *\n * @since 1.0.0\n */\n\n private queuedImplementations: Array<ImplementationType<F>> = [];\n\n /**\n * The current default implementation for this mock.\n *\n * @remarks\n * This property holds the function that will be executed when the mock is called,\n * unless overridden by a queued one-time implementation. It can be set using\n * the `mockImplementation()` method and retrieved with `getMockImplementation()`.\n *\n * If not explicitly set, it defaults to `undefined`, meaning the mock will\n * return `undefined` when called (after any queued implementations are used).\n *\n * This implementation determines the behavior of the mock for all calls that\n * don't have a specific one-time implementation in the queue.\n *\n * @since 1.0.0\n */\n\n private implementation: ImplementationType<F> | undefined;\n\n /**\n * Preserves the original implementation provided when creating the mock.\n *\n * @remarks\n * This property stores the initial function passed to the constructor, allowing\n * the mock to be restored to its original behavior later using `mockRestore()`.\n *\n * If no implementation was provided in the constructor, this will contain a\n * function that returns `undefined` when called.\n *\n * The original implementation is immutable and serves as a reference point\n * for resetting the mock to its initial state.\n *\n * @since 1.0.0\n */\n\n private readonly originalImplementation: ImplementationType<F>;\n\n /**\n * Optional cleanup function to be called when the mock is restored.\n *\n * @remarks\n * If provided, this function will be executed when `mockRestore()` is called,\n * allowing for custom cleanup operations. This is particularly useful when\n * creating mocks that replace methods or properties on existing objects.\n *\n * The restore function should handle any necessary teardown, such as\n * restoring original object properties, removing event listeners, or\n * closing connections that were established during mock creation.\n *\n * @since 1.0.0\n */\n\n private readonly restore?: () => F | void;\n\n /**\n * Creates a new instance of a mock function.\n *\n * @template F - The function type being mocked. This generic type parameter allows\n * the mock to properly type-check parameters and return values to match\n * the function signature being mocked.\n *\n * @param implementation - The initial function implementation to use. If not provided,\n * the mock will return `undefined` when called.\n * @param restore - Optional cleanup function that will be called when `mockRestore()` is invoked.\n * Useful for restoring original behavior when mocking existing object methods.\n * @param name - Optional name for the mock function, used in error messages and test output.\n * Defaults to \"xJet.fn()\" if not provided.\n *\n * @remarks\n * The constructor initializes the mock's state, implementation, and metadata.\n * It returns a Proxy that allows the mock to be both a function and an object with properties.\n *\n * The Proxy intercepts:\n * - Function calls (via `apply`)\n * - Property access (via `get`)\n * - Constructor calls with `new` (via `construct`)\n *\n * This enables the mock to track calls, return configured values, and provide\n * helper methods for assertions and configuration.\n *\n * @see ReturnType\n * @see ImplementationType\n *\n * @since 1.0.0\n */\n\n constructor(implementation?: F, restore?: () => F | void, name?: string) {\n super();\n this.name = name ?? DEFAULT_MOCK_NAME;\n this.state = this.initState();\n this.implementation = implementation || undefined;\n\n this.restore = restore;\n this.originalImplementation = implementation || ((): ReturnType<F> => <ReturnType<F>> undefined);\n\n return <this> new Proxy(this, {\n get: this.invokeGet,\n apply: this.invokeFunction,\n construct: <ProxyHandler<object>['construct']> this.invokeClass\n });\n }\n\n /**\n * Gets a readonly snapshot of the current mocks state.\n *\n * @template F - The function type being mocked.\n *\n * @returns A frozen (immutable) copy of the mock state {@link MocksStateInterface}, containing information\n * about calls, return values, and other tracking data.\n *\n * @remarks\n * This property provides safe access to the mock's internal state for assertions and\n * debugging purposes. The returned object is a deep copy with all properties frozen\n * to prevent accidental modification of the mock's internal state.\n *\n * @see MocksStateInterface\n *\n * @since 1.0.0\n */\n\n get mock(): Readonly<MocksStateInterface<F>> {\n return Object.freeze({ ...this.state });\n }\n\n /**\n * Gets the original function implementation.\n *\n * @template F - The function type being mocked.\n *\n * @returns The original function implementation that was provided when creating the mock\n * or a default implementation that returns undefined if none was provided.\n *\n * @remarks\n * This property allows access to the original implementation that was stored\n * when the mock was created. It's useful when you need to temporarily access\n * or call the original behavior within test cases.\n *\n * @example\n * ```ts\n * // Create a mock with an original implementation\n * const originalFn = (x: number) => x * 2;\n * const mockFn = xJet.fn(originalFn);\n *\n * // Override the implementation for some tests\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * // Call the original implementation directly when needed\n * const result = mockFn.original(5); // Returns 10, not 15\n * ```\n *\n * @since 1.0.0\n */\n\n get original(): F {\n return <F> this.originalImplementation;\n }\n\n /**\n * Clears all information stored in the mock's state {@link MocksStateInterface}.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method resets all stored information such as tracked calls, return values,\n * and other state information. It doesn't reset any custom implementations that\n * were set using mockImplementation or similar methods.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n * mockFn('first call');\n * mockFn('second call');\n *\n * expect(mockFn.mock.calls.length).toBe(2);\n *\n * mockFn.mockClear();\n *\n * // All calls information has been cleared\n * expect(mockFn.mock.calls.length).toBe(0);\n * ```\n *\n * @since 1.0.0\n */\n\n mockClear(): this {\n this.state = this.initState();\n\n return this;\n }\n\n /**\n * Resets the mock by clearing all state and removing all queued implementations.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method performs a more complete reset than mockClear() {@link mockClear}.\n * It clears all stored information about calls and additionally removes any queued implementations that were\n * set using mockImplementationOnce(). The default implementation will be restored.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n * mockFn.mockImplementationOnce(() => 'first call');\n * mockFn.mockImplementationOnce(() => 'second call');\n *\n * console.log(mockFn()); // 'first call'\n *\n * mockFn.mockReset();\n *\n * // All calls have been cleared, and queued implementations removed\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockClear\n * @since 1.0.0\n */\n\n mockReset(): this {\n this.mockClear();\n this.queuedImplementations = [];\n\n return this;\n }\n\n /**\n * Restores the original implementation of the mocked function.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method performs the most complete reset operation. It first calls mockReset() {@link mockReset}\n * to clear all state and queued implementations, then restores the original implementation\n * provided when the mock was created. If a custom restore function was provided,\n * it will be used instead to determine the implementation to restore.\n *\n * @example\n * ```ts\n * // Create a mock with an original implementation\n * const originalFn = (x: number) => x * 2;\n * const mockFn = xJet.fn(originalFn);\n *\n * // Override the implementation\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * console.log(mockFn(5)); // 15\n *\n * // Restore the original implementation\n * mockFn.mockRestore();\n *\n * console.log(mockFn(5)); // 10\n * ```\n *\n * @see mockClear\n * @see mockReset\n *\n * @since 1.0.0\n */\n\n mockRestore(): this {\n this.mockReset();\n const restore = this.restore?.();\n if (typeof restore === 'function') this.implementation = restore;\n else this.implementation = this.originalImplementation;\n\n return this;\n }\n\n /**\n * Returns the current implementation of the mock function.\n *\n * @returns The current mock implementation, or undefined if no implementation exists.\n *\n * @remarks\n * This method returns the current implementation function used by the mock.\n * This could be the default implementation, a custom implementation set via\n * mockImplementation() {@link mockImplementation}, or the original implementation\n * if mockRestore() {@link mockRestore} was called.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * // Get the default implementation\n * const impl = mockFn.getMockImplementation();\n * console.log(impl()); // 'default'\n *\n * // Change the implementation\n * mockFn.mockImplementation(() => 'new implementation');\n *\n * // Get the new implementation\n * const newImpl = mockFn.getMockImplementation();\n * console.log(newImpl()); // 'new implementation'\n * ```\n *\n * @since 1.0.0\n */\n\n getMockImplementation(): ImplementationType<F> | undefined {\n return this.implementation;\n }\n\n /**\n * Returns the next implementation to be used when the mock is called.\n *\n * @returns The next implementation from the queue, or the default implementation if the queue is empty.\n *\n * @remarks\n * This method retrieves and removes the next implementation from the queue of implementations\n * added via mockImplementationOnce() {@link mockImplementationOnce}. If the queue is empty,\n * it returns the default implementation set via mockImplementation() {@link mockImplementation}\n * or the original function.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n * mockFn.mockImplementationOnce(() => 'first call');\n * mockFn.mockImplementationOnce(() => 'second call');\n *\n * const firstImpl = mockFn.getNextImplementation();\n * console.log(firstImpl()); // 'first call'\n *\n * const secondImpl = mockFn.getNextImplementation();\n * console.log(secondImpl()); // 'second call'\n *\n * const defaultImpl = mockFn.getNextImplementation();\n * console.log(defaultImpl()); // 'default'\n * ```\n *\n * @since 1.0.0\n */\n\n getNextImplementation(): ImplementationType<F> | undefined {\n return this.queuedImplementations.length ? this.queuedImplementations.shift() : this.implementation;\n }\n\n /**\n * Sets a new implementation for this mock function.\n *\n * @param fn - The function to be used as the mock implementation.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method sets a persistent implementation that will be used whenever the mock function is called,\n * unless there are queued implementations from mockImplementationOnce() {@link mockImplementationOnce}.\n * The implementation remains until it is replaced by another call to mockImplementation() or restored\n * via mockRestore() {@link mockRestore}.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockImplementation((x: number) => x * 2);\n *\n * console.log(mockFn(5)); // 10\n * console.log(mockFn(10)); // 20\n *\n * // Change the implementation\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * console.log(mockFn(5)); // 15\n * ```\n *\n * @see mockRestore\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockImplementation(fn: ImplementationType<F>): this {\n this.implementation = fn;\n\n return this;\n }\n\n /**\n * Adds a one-time implementation for this mock function.\n *\n * @param fn - The function to be used as the mock implementation for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method queues an implementation that will be used for a single call to the mock function.\n * After being used once, it will be removed from the queue. Multiple implementations can be queued,\n * and they will be used in the order they were added. Once all queued implementations are used,\n * the mock will revert to using the implementation set by mockImplementation() {@link mockImplementation}.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * mockFn.mockImplementationOnce(() => 'first call')\n * .mockImplementationOnce(() => 'second call');\n *\n * console.log(mockFn()); // 'first call'\n * console.log(mockFn()); // 'second call'\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockReset\n * @see mockImplementation\n *\n * @since 1.0.0\n */\n\n mockImplementationOnce(fn: ImplementationType<F>): this {\n this.queuedImplementations.push(fn);\n\n return this;\n }\n\n /**\n * Sets a fixed return value for this mock function.\n *\n * @param value - The value to be returned when the mock function is called.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper around mockImplementation() {@link mockImplementation}\n * that creates an implementation which always returns the same value. It replaces any existing\n * implementation with a function that simply returns the specified value.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockReturnValue(42);\n *\n * console.log(mockFn()); // 42\n * console.log(mockFn('anything')); // 42\n * console.log(mockFn({}, [])); // 42\n *\n * // Can be changed\n * mockFn.mockReturnValue('new value');\n * console.log(mockFn()); // 'new value'\n * ```\n *\n * @see mockImplementation\n * @see mockReturnValueOnce\n *\n * @since 1.0.0\n */\n\n mockReturnValue(value: ReturnType<F>): this {\n this.mockImplementation(() => value);\n\n return this;\n }\n\n /**\n * Adds a one-time fixed return value for this mock function.\n *\n * @param value - The value to be returned for a single call to the mock function.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper around mockImplementationOnce() {@link mockImplementationOnce}\n * that creates a one-time implementation which returns the specified value. Multiple return values\n * can be queued, and they will be used in the order they were added. After all queued values are\n * consumed, the mock will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * mockFn.mockReturnValueOnce(42)\n * .mockReturnValueOnce('string value')\n * .mockReturnValueOnce({ object: true });\n *\n * console.log(mockFn()); // 42\n * console.log(mockFn()); // 'string value'\n * console.log(mockFn()); // { object: true }\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockReturnValue\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockReturnValueOnce(value: ReturnType<F>): this {\n this.mockImplementationOnce(() => value);\n\n return this;\n }\n\n /**\n * Sets a resolved Promise return value for this mock function.\n *\n * @param value - The value that the Promise will resolve to.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates an implementation which returns a\n * Promise that resolves to the specified value. It's particularly useful for testing\n * async functions that should return resolved Promises.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockResolvedValue('resolved value');\n *\n * // The mock now returns a Promise that resolves to 'resolved value'\n * mockFn().then(result => {\n * console.log(result); // 'resolved value'\n * });\n *\n * // Can also be used with async/await\n * const result = await mockFn();\n * console.log(result); // 'resolved value'\n * ```\n *\n * @see mockRejectedValue\n * @see mockImplementation\n * @see mockResolvedValueOnce\n *\n * @since 1.0.0\n */\n\n mockResolvedValue(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementation(() => <ReturnType<F>> Promise.resolve(value));\n\n return this;\n }\n\n /**\n * Adds a one-time resolved Promise return value for this mock function.\n *\n * @param value - The value that the Promise will resolve to for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates a one-time implementation which returns\n * a Promise that resolves to the specified value. Multiple resolved values can be queued and\n * will be used in the order they were added. After all queued values are consumed, the mock\n * will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => Promise.resolve('default'));\n *\n * mockFn.mockResolvedValueOnce('first call')\n * .mockResolvedValueOnce('second call')\n * .mockResolvedValueOnce('third call');\n *\n * // Each call returns a different Promise\n * await expect(mockFn()).resolves.toEqual('first call');\n * await expect(mockFn()).resolves.toEqual('second call');\n * await expect(mockFn()).resolves.toEqual('third call');\n * await expect(mockFn()).resolves.toEqual('default');\n * ```\n *\n * @see mockResolvedValue\n * @see mockRejectedValueOnce\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockResolvedValueOnce(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementationOnce(() => <ReturnType<F>> Promise.resolve(value));\n\n return this;\n }\n\n /**\n * Sets a rejected Promise return value for this mock function.\n *\n * @param value - The error that the Promise will reject with.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates an implementation which returns a\n * Promise that rejects with the specified value. It's particularly useful for testing\n * error handling in async functions.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockRejectedValue(new Error('Something went wrong'));\n *\n * // The mock now returns a Promise that rejects with the error\n * mockFn().catch(error => {\n * console.error(error.message); // 'Something went wrong'\n * });\n *\n * // Can also be used with async/await and try/catch\n * try {\n * await mockFn();\n * } catch (error) {\n * console.error(error.message); // 'Something went wrong'\n * }\n * ```\n *\n * @see mockResolvedValue\n * @see mockImplementation\n * @see mockRejectedValueOnce\n *\n * @since 1.0.0\n */\n\n mockRejectedValue(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementation(() => <ReturnType<F>> Promise.reject(value));\n\n return this;\n }\n\n /**\n * Adds a one-time rejected Promise return value for this mock function.\n *\n * @param value - The error that the Promise will reject with for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates a one-time implementation which returns\n * a Promise that rejects with the specified value. Multiple rejected values can be queued and\n * will be used in the order they were added. After all queued values are consumed, the mock\n * will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => Promise.resolve('success'));\n *\n * mockFn.mockRejectedValueOnce(new Error('first error'))\n * .mockRejectedValueOnce(new Error('second error'));\n *\n * // First call rejects with 'first error'\n * await expect(mockFn()).rejects.toThrow('first error');\n *\n * // Second call rejects with 'second error'\n * await expect(mockFn()).rejects.toThrow('second error');\n *\n * // Third call uses the default implementation and resolves\n * await expect(mockFn()).resolves.toEqual('success');\n * ```\n *\n * @see mockRejectedValue\n * @see mockResolvedValueOnce\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockRejectedValueOnce(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementationOnce(() => <ReturnType<F>> Promise.reject(value));\n\n return this;\n }\n\n /**\n * Custom inspection method for Node.js util.inspect().\n *\n * @returns A string representation of this mock constructor.\n *\n * @remarks\n * This method implements the Node.js custom inspection protocol by using the\n * Symbol.for('nodejs.util.inspect.custom') symbol. When the mock is inspected\n * using util.inspect() or displayed in a Node.js REPL, this custom string\n * representation will be used instead of the default object inspection.\n *\n * @example\n * ```ts\n * const mockConstructor = xJet.fn();\n * console.log(mockConstructor); // Outputs: <Mock Constructor undefined>\n *\n * const namedMock = xJet.fn().mockName('myMock');\n * console.log(namedMock); // Outputs: <Mock Constructor myMock>\n * ```\n *\n * @see https://nodejs.org/api/util.html#util_custom_inspection_functions_on_objects\n *\n * @since 1.0.0\n */\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return `<Mock Constructor ${ this.name }>`;\n }\n\n /**\n * Initializes the internal state object for the mock function.\n *\n * @returns A new mock state object with default empty values.\n *\n * @remarks\n * This private method creates and returns a fresh state object used to track\n * mock function invocations. The state includes:\n * - calls: Arguments passed to the mock function\n * - results: Return values or errors from each call\n * - lastCall: Arguments from the most recent call\n * - contexts: 'this' context values for each call\n * - instances: Objects created when the mock is used as a constructor\n * - invocationCallOrder: Tracking the sequence of calls across multiple mocks\n *\n * This method is used internally when creating a new mock or when resetting\n * an existing mocks state.\n *\n * @since 1.0.0\n */\n\n private initState(): MocksStateInterface<F> {\n return {\n calls: [],\n results: [],\n lastCall: undefined,\n contexts: [],\n instances: [],\n invocationCallOrder: []\n };\n }\n\n /**\n * Invokes the mock function with the provided arguments and context.\n *\n * @param thisArg - The 'this' context for the function call\n * @param args - The arguments to pass to the function\n * @returns The result of the mock implementation or undefined\n *\n * @remarks\n * This private method handles the actual invocation of the mock function and manages all\n * state trackings.\n *\n * This method is central to the mock's functionality, enabling call tracking,\n * result recording, and the execution of custom implementations.\n *\n * @since 1.0.0\n */\n\n private invoke(thisArg: ThisParameterType<F>, args: Parameters<F>): ReturnType<F> | undefined {\n let thisContext = thisArg;\n const impl = <FunctionType & BoundInterface> this.getNextImplementation();\n\n const argsArray = <Parameters<F>> args;\n if (typeof impl === 'function') {\n if (impl.__boundArgs) argsArray.unshift(...impl.__boundArgs);\n if (impl.__boundThis) thisContext = <ThisParameterType<F>> impl.__boundThis;\n }\n\n this.state.calls.push(argsArray);\n this.state.contexts.push(<ThisParameterType<F>> thisContext);\n this.state.invocationCallOrder.push(this.state.invocationCallOrder.length + 1);\n\n let result: MockInvocationResultInterface<ReturnType<F>>;\n const index = this.state.results.push({ value: undefined, type: 'incomplete' }) - 1;\n\n if (impl) {\n try {\n const value = impl.call(<ThisParameterType<F>> undefined, ...args);\n result = { type: 'return', value };\n } catch (error) {\n result = { value: error, type: 'throw' };\n }\n } else {\n result = { type: 'return', value: undefined };\n }\n\n this.state.lastCall = args;\n this.state.results[index] = result;\n\n return <ReturnType<F>> result.value;\n }\n\n /**\n * Handles property access for the mock function proxy.\n *\n * @param target - The mock function instance\n * @param property - The property name or symbol being accessed\n * @returns The property value from either the mock or the original implementation\n *\n * @remarks\n * This private method is used as the 'get' trap for the Proxy surrounding the mock function.\n * It provides property access fallback behavior - first checking if the property exists\n * on the mock itself, and if not, retrieving it from the original implementation.\n *\n * This enables the mock to maintain its own properties while still allowing access to\n * properties from the original function, providing a more transparent mocking experience.\n *\n * @since 1.0.0\n */\n\n private invokeGet(target: this, property: string | symbol): unknown {\n const isProperty = Reflect.has(target, property);\n if (isProperty) return Reflect.get(target, property);\n\n return Reflect.get(target.originalImplementation, property);\n }\n\n /**\n * Handles constructor invocation when the mock is used with 'new'.\n *\n * @param target - The mock function instance\n * @param argArray - The arguments passed to the constructor\n * @param newTarget - The constructor that was directly invoked\n * @returns The constructed instance\n *\n * @remarks\n * This method is used as the 'construct' trap for the Proxy surrounding the mock function.\n * It delegates to the `invoke` method to handle the actual function call, then tracks the\n * resulting instance in the mock's state for later verification.\n *\n * The method handles both cases where the constructor returns an object (which becomes the\n * instance) and where it doesn't (in which case the newTarget becomes the instance).\n *\n * @since 1.0.0\n */\n\n private invokeClass(target: this, argArray: Parameters<F>, newTarget: object): object {\n const result = target.invoke.call(target, <ThisParameterType<F>> newTarget, argArray);\n const isClassInstance = typeof result === 'object' && result !== null && 'constructor' in result;\n target.state.instances.push(isClassInstance ? <ThisParameterType<F>> result : <ThisParameterType<F>> newTarget);\n\n return typeof result === 'object' ? <object> result : newTarget;\n }\n\n /**\n * Handles function invocation when the mock is called.\n *\n * @param target - The mock function instance\n * @param thisArg - The 'this' context for the function call\n * @param argumentsList - The arguments passed to the function\n * @returns The result of the function invocation\n *\n * @remarks\n * This method is used as the 'apply' trap for the Proxy surrounding the mock function.\n * It captures the calling context in the mock's state for later verification, then\n * delegates to the `invoke` method to handle the actual function call logic.\n *\n * This method is called whenever the mock function is invoked as a regular function\n * (not as a constructor).\n *\n * @since 1.0.0\n */\n\n private invokeFunction(target: this, thisArg: ThisParameterType<F>, argumentsList: Parameters<F>): ReturnType<F> | undefined {\n target.state.instances.push(thisArg);\n\n return target.invoke.call(target, thisArg, argumentsList);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConstructorType } from '@remotex-labs/xjet-expect';\nimport type { InjectableOptionsInterface, TokenElementType } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * Stores singleton instances of injectable classes.\n *\n * @since 1.0.0\n */\n\nconst SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for classes marked as injectable via `@Injectable`.\n *\n * @internal\n * @since 1.0.0\n */\n\nconst INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Marks a class as injectable and stores its configuration metadata.\n *\n * @template T - The type of the class instance\n * @template Args - The types of arguments accepted by the constructor, defaults to `unknown[]`\n *\n * @param options - Optional configuration for the injectable, including scope and factory\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 1.0.0\n */\n\nexport function Injectable<T = unknown, Args extends Array<unknown> = unknown[]>(options?: InjectableOptionsInterface) {\n return function (target: new (...args: Args) => T): void {\n INJECTABLES.set(target, options || {});\n };\n}\n\n/**\n * Resolves and returns an instance of the given injectable token.\n *\n * @template T - The type of the instance to return\n * @template Args - The types of arguments passed to the constructor or factory\n *\n * @param token - The injectable class or token to resolve\n * @param args - Arguments to pass to the constructor or factory\n *\n * @returns The resolved instance of type `T`\n *\n * @throws Error - If the token is not registered as injectable via `@Injectable`\n *\n * @remarks\n * If the injectable is marked with scope `'singleton'`, the same instance will be returned\n * on the following calls. Otherwise, a new instance is created for each call.\n *\n * @example\n * ```ts\n * const service = inject(MyService);\n * ```\n *\n * @see TokenElementType\n * @since 1.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: TokenElementType<T, Args>, ...args: Args): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token);\n if (!metadata) throw new Error(`Cannot inject ${ token.name } \u2013 not marked @Injectable`);\n\n const instance: T = metadata.factory\n ? <T>metadata.factory(...args)\n : new token(...args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { MessageType } from '@messages/constants/report.constant';\nimport type { EmitEventInterface, EmitStatusInterface } from '@shared/services/interfaces/emit-service.interface';\n\n/**\n * Imports\n */\n\nimport { serializeError } from '@remotex-labs/xjet-expect';\nimport { encodePacket, PacketKind } from '@packets/packets.module';\n\n/**\n * Emits a status update packet to the dispatcher.\n *\n * @param type - The {@link MessageType} representing the kind of status (e.g., suite start, suite end).\n * @param notification - The {@link EmitStatusInterface} containing ancestry and description details.\n *\n * @remarks\n * This function encodes the notification into a `PacketKind.Status` packet\n * and sends it via the global `dispatch` mechanism.\n *\n * @see MessageType\n * @see encodePacket\n * @see PacketKind.Status\n * @see EmitStatusInterface\n *\n * @since 1.0.0\n */\n\nexport function emitStatus(type: MessageType, notification: EmitStatusInterface = {}): void {\n dispatch(encodePacket(PacketKind.Status, {\n type: type,\n todo: notification?.todo,\n skipped: notification?.skipped,\n duration: notification?.duration,\n ancestry: notification?.ancestry?.join(','),\n description: notification?.description\n }));\n}\n\n/**\n * Emits an action (event) packet to the dispatcher.\n *\n * @param type - The {@link MessageType} representing the kind of action (e.g., test end, describe end).\n * @param notification - The {@link EmitEventInterface} containing ancestry, description,\n * duration, and possible test errors.\n *\n * @remarks\n * - Errors are serialized with {@link serializeError} before being encoded.\n * - The function encodes the notification into a `PacketKind.Events` packet\n * and sends it via the global `dispatch` mechanism.\n *\n * @see MessageType\n * @see encodePacket\n * @see serializeError\n * @see PacketKind.Events\n * @see EmitEventInterface\n *\n * @since 1.0.0\n */\n\nexport function emitEvent(type: MessageType, notification: EmitEventInterface): void {\n const stringErrors = notification.errors?.map((error: Error) =>\n serializeError(error)\n ) || [];\n\n dispatch(encodePacket(PacketKind.Events, {\n type: type,\n errors: stringErrors.length > 0 ? JSON.stringify(stringErrors) : '',\n ancestry: notification.ancestry.join(''),\n duration: notification.duration,\n description: notification.description\n }));\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketHeaderInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { DecodedPacketType, PacketPayloadMapType } from '@packets/interfaces/packets.interface';\n\n/**\n * Imports\n */\n\nimport { serializeError } from '@remotex-labs/xjet-expect';\nimport { PacketKind } from '@packets/constants/packet-schema.constants';\nimport { errorSchema, headerSchema } from '@packets/schema/packet.schema';\nimport { PacketSchemas } from '@packets/constants/packet-schema.constants';\n\n/**\n * Exports constants\n */\n\nexport * from '@packets/constants/packet-schema.constants';\n\n/**\n * Exports interfaces\n */\n\nexport * from '@packets/interfaces/packets.interface';\nexport * from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Encodes a packet of a given kind into a `Buffer`.\n *\n * @template T - The packet kind (`PacketKind.Log`, `PacketKind.Error`, `PacketKind.Status`, or `PacketKind.Events`)\n *\n * @param kind - The type of packet to encode\n * @param data - Partial data matching the packet type; will be combined with header information\n *\n * @returns A `Buffer` containing the serialized packet\n *\n * @throws Error if the provided `kind` does not correspond to a known packet schema\n *\n * @remarks\n * This function combines a header and the payload according to the packet kind.\n * The header includes the suite ID, runner ID, and a timestamp.\n *\n * @since 1.0.0\n */\n\nexport function encodePacket<T extends PacketKind>(kind: T, data: Partial<PacketPayloadMapType[T]>): Buffer {\n const schema = PacketSchemas[kind];\n if (!schema) throw new Error(`Invalid schema kind: ${ kind }`);\n\n const header: PacketHeaderInterface = {\n kind: kind,\n suiteId: globalThis?.__XJET?.runtime?.suiteId ?? '',\n runnerId: globalThis?.__XJET?.runtime.runnerId ?? '',\n timestamp: (new Date()).toISOString()\n };\n\n return Buffer.concat([\n headerSchema.toBuffer(header),\n schema.toBuffer(data)\n ]);\n}\n\n/**\n * Decodes a packet from a `Buffer` into its corresponding object representation.\n *\n * @template T - The expected packet kind (`PacketKind.Log`, `PacketKind.Error`, `PacketKind.Status`, or `PacketKind.Events`)\n *\n * @param buffer - The buffer containing the encoded packet\n * @returns The decoded packet object, combining the header and payload fields\n *\n * @throws Error if the packet kind is unknown or invalid\n *\n * @remarks\n * Decodes both the header and payload based on the packet kind.\n *\n * @since 1.0.0\n */\n\nexport function decodePacket<T extends PacketKind>(buffer: Buffer): DecodedPacketType<T> {\n let offset = headerSchema.size;\n const header = headerSchema.toObject(buffer, (dynamicOffset: number): void => {\n offset += dynamicOffset;\n });\n\n const type = header.kind as PacketKind;\n const schema = PacketSchemas[type];\n if (!schema) {\n throw new Error(`Unknown packet kind: ${ type }`);\n }\n\n const dataBuffer = buffer.subarray(offset);\n const data = schema.toObject(dataBuffer) as PacketPayloadMapType[T];\n\n return { ...header, ...data };\n}\n\n/**\n * Encodes an {@link Error} instance into a binary buffer following the packet schema.\n *\n * @param error - The error object to be serialized and encoded.\n * @param suiteId - Identifier of the suite where the error occurred.\n * @param runnerId - Identifier of the runner reporting the error.\n *\n * @returns A {@link Buffer} containing the encoded error packet, ready for transmission.\n *\n * @remarks\n * The function creates two binary sections:\n * - A **header**, describing the packet kind (`Error`), suite ID, runner ID, and timestamp.\n * - A **data buffer**, holding the serialized error details in JSON format.\n *\n * These two sections are concatenated into a single buffer.\n *\n * @example\n * ```ts\n * try {\n * throw new Error(\"Test failed\");\n * } catch (err) {\n * const buffer = encodeErrorSchema(err, \"suite-123\", \"runner-456\");\n * socket.send(buffer); // transmit over a transport channel\n * }\n * ```\n *\n * @see serializeError\n * @see PacketKind.Error\n *\n * @since 1.0.0\n */\n\nexport function encodeErrorSchema(error: Error, suiteId: string, runnerId: string): Buffer {\n const header = headerSchema.toBuffer({\n kind: PacketKind.Error,\n suiteId: suiteId ?? '',\n runnerId: runnerId ?? '',\n timestamp: (new Date()).toISOString()\n });\n\n const dataBuffer = errorSchema.toBuffer({\n error: JSON.stringify(serializeError(error))\n });\n\n return Buffer.concat([ header, dataBuffer ]);\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketLogInterface, PacketStatusInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { PacketErrorInterface, PacketEventsInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { PacketHeaderInterface, PacketInvocationInterface } from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Imports\n */\n\nimport { Struct } from '@remotex-labs/xstruct';\n\n/**\n * Schema for serializing and deserializing {@link PacketInvocationInterface} data.\n *\n * @remarks\n * Represents the location in source code where a test, describe, or log originates.\n *\n * @since 1.0.0\n */\n\nexport const invocationSchema = new Struct<PacketInvocationInterface>({\n line: 'UInt32LE',\n column: 'UInt32LE',\n source: 'string'\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketHeaderInterface} data.\n *\n * @remarks\n * Contains metadata for each packet, including kind, suite and runner identifiers, and timestamp.\n *\n * @since 1.0.0\n */\n\nexport const headerSchema = new Struct<PacketHeaderInterface>({\n kind: 'UInt8:4',\n suiteId: { type: 'string', size: 14 },\n runnerId: { type: 'string', size: 14 },\n timestamp: 'string'\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketLogInterface} data.\n *\n * @remarks\n * Used for console-like logs emitted by tests or describes, including message, level, ancestry, and invocation.\n *\n * @since 1.0.0\n */\n\nexport const logSchema = new Struct<PacketLogInterface>({\n level: 'UInt8',\n message: { type: 'string', lengthType: 'UInt32LE' },\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n invocation: invocationSchema\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketErrorInterface} data.\n *\n * @remarks\n * Represents suite-level fatal errors that are not tied to specific tests or describes.\n *\n * @since 1.0.0\n */\n\nexport const errorSchema = new Struct<PacketErrorInterface>({\n error: { type: 'string', lengthType: 'UInt32LE' }\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketStatusInterface} data.\n *\n * @remarks\n * Represents status updates for individual tests or describe blocks,\n * including whether it is TODO, skipped, and its ancestry and description.\n *\n * @since 1.0.0\n */\n\nexport const statusSchema = new Struct<PacketStatusInterface>({\n type: 'UInt8:5',\n todo: 'UInt8:1',\n skipped: 'UInt8:1',\n duration: 'UInt32LE',\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n description: { type: 'string', lengthType: 'UInt32LE' }\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketEventsInterface} data.\n *\n * @remarks\n * Represents events emitted during the test or describe execution,\n * including pass/fail status, duration, error messages, ancestry, and invocation.\n *\n * @since 1.0.0\n */\n\nexport const eventsSchema = new Struct<PacketEventsInterface>({\n type: 'UInt8:5',\n passed: 'UInt8:1',\n duration: 'UInt32LE',\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n description: { type: 'string', lengthType: 'UInt32LE' },\n errors: { type: 'string', lengthType: 'UInt32LE' }\n});\n", "/**\n * Import will remove at compile time\n */\n\nimport type { Struct } from '@remotex-labs/xstruct';\n\n/**\n * Imports\n */\n\nimport { errorSchema, eventsSchema, logSchema, statusSchema } from '@packets/schema/packet.schema';\n\n/**\n * Defines the different kinds of packets that can be transmitted or received.\n *\n * @remarks\n * Each packet kind corresponds to a specific type of event or message in the test framework:\n * - `Log`: Console or logging messages\n * - `Error`: Suite-level fatal errors\n * - `Status`: Test or describe start events, including `skipped` and `todo` flags\n * - `Events`: Test or describe end events, only for completed tests/describes (no skipped or TODO)\n *\n * @since 1.0.0\n */\n\nexport const enum PacketKind {\n /**\n * Represents a log message packet, e.g., `console.log`, `console.error`.\n * @since 1.0.0\n */\n\n Log = 1,\n\n /**\n * Represents a fatal suite-level error.\n * Not associated with any test, describe, or hook.\n * @since 1.0.0\n */\n\n Error = 2,\n\n /**\n * Represents a status packet for test or describe start events.\n *\n * @remarks\n * Includes flags for:\n * - `skipped`: Whether the test or describe was skipped\n * - `todo`: Whether the test is marked as TODO\n *\n * @since 1.0.0\n */\n\n Status = 3,\n\n /**\n * Represents an event packet for test or describe end events.\n *\n * @remarks\n * Only includes completed tests/describes; skipped or TODO tests are not included.\n * Contains information such as `passed` and `duration`.\n *\n * @since 1.0.0\n */\n\n Events = 4\n}\n\n/**\n * Maps each {@link PacketKind} to its corresponding {@link Struct} schema for serialization/deserialization.\n *\n * @remarks\n * This object allows encoding and decoding packets of different kinds using\n * their respective `xStruct` schemas. Use `PacketSchemas[PacketKind.Log]` to\n * get the schema for log packets, etc.\n *\n * @see PacketKind\n * @see Struct\n *\n * @since 1.0.0\n */\n\nexport const PacketSchemas: Record<PacketKind, Struct> = {\n [PacketKind.Log]: logSchema,\n [PacketKind.Error]: errorSchema,\n [PacketKind.Status]: statusSchema,\n [PacketKind.Events]: eventsSchema\n} as const;\n", "/**\n * Defines the log verbosity levels for reporters and test execution.\n *\n * @remarks\n * Each level represents the minimum severity of messages that should be\n * captured or displayed. Higher levels include all messages from lower levels.\n *\n * @example\n * ```ts\n * if (log.level >= LogLevel.Warn) {\n * console.warn(log.message);\n * }\n * ```\n *\n * @since 1.0.0\n */\n\nexport enum LogLevel {\n Silent = 0,\n Error = 1,\n Warn = 2,\n Info = 3,\n Debug = 4\n}\n\n/**\n * Defines the types of messages emitted during test execution.\n *\n * @remarks\n * These message types are used internally by reporters, runners,\n * and event emitters to categorize test events. Each type corresponds\n * to a specific stage or element of the test lifecycle.\n *\n * @example\n * ```ts\n * if (message.type === MessageType.Test) {\n * console.log('Test event received');\n * }\n * ```\n *\n * @since 1.0.0\n */\n\nexport const enum MessageType {\n Test = 1,\n Describe = 2,\n EndSuite = 3,\n StartSuite = 4\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { HookModel } from './hook.model';\nimport type { TestModel } from '@shared/models/test.model';\nimport type { ContextType } from '@remotex-labs/xjet-expect';\nimport type { ContextInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeHooksInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { MessageType } from '@messages/constants/report.constant';\nimport { emitEvent, emitStatus } from '@shared/services/emit.service';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\n\n/**\n * Represents a test suite container that manages test execution flow and hierarchy\n *\n * @template T - Context type for test execution\n * @param description - The description of the test suite\n * @param describeFlags - Configuration options for the test suite\n * @returns A new DescribeModel instance that can contain tests and nested suites\n *\n * @remarks\n * The DescribeModel manages the execution lifecycle of tests, including\n * - Maintaining parent-child relationships between test suites\n * - Executing hooks in the correct order (beforeAll, beforeEach, afterEach, afterAll)\n * - Tracking test execution status and reporting results\n * - Supporting test filtering with skip/only options\n *\n * @example\n * ```ts\n * const rootSuite = new DescribeModel('Root suite');\n * const testCase = new TestModel('should work', () => {\n * expect(true).toBe(true);\n * });\n * rootSuite.addTest(testCase);\n * await rootSuite.run({});\n * ```\n *\n * @see TestModel\n * @see HookModel\n * @see DescribeHooksInterface\n *\n * @since 1.0.0\n */\n\nexport class DescribeModel {\n /**\n * Array containing the hierarchical path of parent describe blocks for this test suite\n *\n * @since 1.0.0\n */\n\n readonly ancestry: string[] = [];\n\n /**\n * Collection of test cases directly contained within this test suite\n *\n * @internal\n * @since 1.0.0\n */\n\n readonly testsStack: TestModel[] = [];\n\n /**\n * Collection of nested test suites within this suite\n *\n * @internal\n * @since 1.0.0\n */\n\n readonly describesStack: DescribeModel[] = [];\n\n /**\n * Timestamp when the test suite execution started\n *\n * @default 0\n * @internal\n * @since 1.0.0\n */\n\n private startTime = 0;\n\n /**\n * Collection of lifecycle hooks for this test suite\n *\n * @internal\n * @since 1.0.0\n */\n\n private readonly hooks: DescribeHooksInterface = {\n afterAll: [],\n afterEach: [],\n beforeAll: [],\n beforeEach: []\n };\n\n /**\n * Creates a new test suite with the specified description and options\n *\n * @param description - Human-readable description of the test suite\n * @param describeOptions - Configuration options to control test suite execution\n *\n * @since 1.0.0\n */\n\n constructor(\n readonly description: string = '',\n private readonly describeOptions: DescribeOptionsInterface = { skip: false, only: false }\n ) {\n }\n\n /**\n * Retrieves the execution configuration options for this test suite\n *\n * @returns Test suite configuration options\n *\n * @since 1.0.0\n */\n\n get options(): DescribeOptionsInterface {\n return this.describeOptions;\n }\n\n /**\n * Gets all tests in this suite, including tests from nested suites\n *\n * @returns Flattened array of all tests in this suite and its children\n *\n * @remarks\n * Recursively collects and flattens all test cases from this suite and any nested suites\n *\n * @since 1.0.0\n */\n\n get tests(): TestModel[] {\n // Use flatMap for cleaner code and better performance\n return [\n ...this.testsStack,\n ...this.describesStack.flatMap(child => child.tests)\n ];\n }\n\n /**\n * Registers a hook function to be executed at a specific point in the test lifecycle\n *\n * @param type - The lifecycle point at which to execute the hook\n * @param hook - The hook function model to register\n *\n * @throws Error - If an invalid hook type is provided\n *\n * @since 1.0.0\n */\n\n addHook(type: HookType, hook: HookModel): void {\n const hookArray = this.hooks[type];\n if (!hookArray) {\n throw new Error(`Invalid hook type: ${ type }`);\n }\n\n hookArray.push(hook);\n }\n\n /**\n * Adds a test case to this test suite\n *\n * @param test - The test model to add to the suite\n *\n * @remarks\n * When adding a test, this method automatically:\n * - Updates the test's ancestry to include this suite\n * - Propagates execution options (skip/only) from the suite to the test\n *\n * @since 1.0.0\n */\n\n addTest(test: TestModel): void {\n if (!test) return;\n\n test.setAncestry(this.ancestry);\n if (this.description) test.setAncestry([ this.description ]);\n test.applyExecutionFlags(this.options.skip, this.options.only);\n this.testsStack.push(test);\n }\n\n /**\n * Adds a nested test describe to this test describe\n *\n * @param describe - The child test describe to add\n *\n * @remarks\n * When adding nested describe, this method automatically:\n * - Sets up the parent-child relationship\n * - Propagates execution options and ancestry information from parent to child\n *\n * @since 1.0.0\n */\n\n addDescribe(describe: DescribeModel): void {\n if (!describe) return;\n\n describe.inheritFromParentDescribe(this);\n this.describesStack.push(describe);\n }\n\n /**\n * Executes the test suite and all contained tests\n *\n * @param context - The test execution context containing shared state\n * @returns Promise that resolves when all tests in the suite complete\n *\n * @remarks\n * Execution follows this order:\n * 1. Check if the suite is marked as skipped\n * 2. Execute all beforeAll hooks\n * 3. Run all tests in this suite\n * 4. Run all nested test suites\n * 5. Execute all afterAll hooks\n * If any step fails, the entire suite is marked as failed\n *\n * @example\n * ```ts\n * const suite = new DescribeModel('My test suite');\n * const context = createTestContext();\n * await suite.run(context);\n * ```\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<ContextInterface>): Promise<void> {\n this.startTime = Date.now();\n this.notifyDescribeStatus(this.options.skip);\n const afterAllErrorsEmpty = !context.afterAllErrors?.length;\n const beforeAllErrorsEmpty = !context.beforeAllErrors?.length;\n\n try {\n if (!context.beforeAllErrors?.length)\n await this.executeHooks(HookType.BEFORE_ALL, context);\n\n for (const test of this.shuffleTests(this.testsStack)) {\n if(context.hasError) return;\n await test.run(context, this.executeHooks.bind(this));\n }\n\n for (const describe of this.describesStack) {\n if(context.hasError) return;\n await describe.run(context);\n }\n\n await this.executeHooks(HookType.AFTER_ALL, context);\n\n if (context.afterAllErrors?.length) this.notifyDescribeFailure(context.afterAllErrors);\n else this.notifyDescribeAction();\n } catch (error) {\n this.notifyDescribeFailure([ error, ...context.afterAllErrors ]);\n if(globalThis.__XJET?.runtime.bail) {\n context.hasError = true;\n }\n } finally {\n if (afterAllErrorsEmpty) context.afterAllErrors = [];\n if (beforeAllErrorsEmpty) context.beforeAllErrors = [];\n }\n }\n\n /**\n * Inherits properties from a parent test suite\n *\n * @param parent - The parent test describe to inherit from\n *\n * @remarks\n * This method performs the following inheritance operations:\n * - Adds parent's ancestry chain to this suite's ancestry\n * - Propagates the 'skip' flag (if parent is skipped, child is skipped)\n * - Propagates the 'only' flag if the parent has it set\n *\n * @since 1.0.0\n */\n\n inheritFromParentDescribe(parent: DescribeModel): void {\n this.ancestry.push(...parent.ancestry);\n this.hooks.beforeEach = [ ...parent.hooks.beforeEach, ...this.hooks.beforeEach ];\n this.hooks.afterEach = [ ...parent.hooks.afterEach, ...this.hooks.afterEach ];\n\n if (parent.description)\n this.ancestry.push(parent.description);\n\n if (parent.options.skip) {\n this.describeOptions.skip = true;\n }\n\n if (parent.options.only) {\n this.describeOptions.only = true;\n }\n }\n\n /**\n * Executes all hooks of the specified type in sequence\n *\n * @param type - The lifecycle hook type to execute\n * @param context - The test execution context\n *\n * @throws Error - When a beforeEach or afterEach hook fails\n *\n * @remarks\n * Errors in beforeAll hooks are collected but don't immediately abort execution.\n * Errors in afterAll hooks are collected for reporting.\n * Errors in beforeEach/afterEach hooks cause immediate test failure.\n *\n * @internal\n * @since 1.0.0\n */\n\n private async executeHooks(type: HookType, context: ContextType<ContextInterface>): Promise<void> {\n if (this.options.skip) return;\n context.beforeAllErrors = context.beforeAllErrors || [];\n context.afterAllErrors = context.afterAllErrors || [];\n\n for (const hook of this.hooks[type]) {\n try {\n await hook.run(context);\n } catch (error) {\n await this.handleHookError(type, error, context);\n }\n }\n }\n\n /**\n * Handles errors that occur during hook execution\n *\n * @param type - The type of hook where the error occurred\n * @param error - The error that was thrown\n * @param context - The test execution context\n *\n * @throws Error - When the error occurs in a beforeEach or afterEach hook\n *\n * @remarks\n * Error handling differs by hook type:\n * - beforeAll: Error is collected but execution continues\n * - afterAll: Error is collected for reporting\n * - beforeEach/afterEach: Error is immediately thrown to fail the test\n *\n * @internal\n *\n * @since 1.0.0\n */\n\n private async handleHookError(type: HookType, error: unknown, context: ContextType<ContextInterface>): Promise<void> {\n if (type === HookType.BEFORE_ALL) {\n context.beforeAllErrors.push(error);\n } else if (type === HookType.AFTER_ALL) {\n context.afterAllErrors.push(error);\n } else {\n throw error;\n }\n }\n\n /**\n * Calculates the execution duration of the test suite in milliseconds\n *\n * @returns Duration in milliseconds since the test started, or 0 if not started\n *\n * @remarks\n * Returns the elapsed time between when the suite started execution and the current time\n * If the suite hasn't started (startTime is 0), returns 0 instead\n *\n * @internal\n * @since 1.0.0\n */\n\n private getExecutionDuration(): number {\n if (this.startTime === 0)\n return 0;\n\n return Date.now() - this.startTime;\n }\n\n private notifyDescribeStatus(skip: boolean = false): void {\n emitStatus(MessageType.Describe, {\n skipped: skip,\n ancestry: this.ancestry,\n description: this.description\n });\n }\n\n private notifyDescribeAction(errors: Array<unknown> = []): void {\n emitEvent(MessageType.Describe, {\n errors: <Array<Error>> errors,\n ancestry: this.ancestry,\n description: this.description,\n duration: this.getExecutionDuration()\n });\n }\n\n /**\n * Reports test suite failure with associated errors\n *\n * @param errors - Collection of errors that caused the test suite to fail\n *\n * @remarks\n * Skips reporting if no errors are provided\n * Uses notifyDescribeAction to emit a failure event with the error details\n *\n * @internal\n * @since 1.0.0\n */\n\n private notifyDescribeFailure(errors: Array<unknown>): void {\n if (!errors?.length) return;\n\n this.notifyDescribeAction(errors);\n }\n\n /**\n * Randomizes the order of tests in an array using the Fisher-Yates shuffle algorithm\n *\n * @param testsToShuffle - Array of test models to be randomly reordered\n * @returns The same array with elements potentially reordered in a random sequence\n *\n * @remarks\n * The shuffling only occurs if the global randomization flag is enabled\n * (accessed via globalThis.__XJET?.runtime.randomize) and the array has more\n * than one element. The algorithm used is Fisher-Yates shuffle, which ensures\n * each permutation has equal probability.\n *\n * @example\n * ```ts\n * const tests = [new TestModel('test1'), new TestModel('test2')];\n * const randomizedTests = this.shuffleTests(tests);\n * // The order of tests may be different from the original if randomization is enabled\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n private shuffleTests(testsToShuffle: Array<TestModel>): Array<TestModel> {\n const randomize = globalThis.__XJET?.runtime.randomize ?? false;\n if (!randomize || testsToShuffle.length <= 1) return testsToShuffle;\n const length = testsToShuffle.length;\n\n // Start from the last element and swap with a random element\n // before the current position (including itself)\n for (let i = length - 1; i > 0; i--) {\n // Generate a random index from 0 to i (inclusive)\n const j = Math.floor(Math.random() * (i + 1));\n\n // Swap elements at indices i and j\n // Use destructuring assignment for a clean swap without a temp variable\n [ testsToShuffle[i], testsToShuffle[j] ] = [ testsToShuffle[j], testsToShuffle[i] ];\n }\n\n return testsToShuffle;\n }\n}\n", "/**\n * A base error class that extends the standard Error class with enhanced JSON serialization and location tracking\n *\n * @param message - The error message describing what went wrong\n * @param location - The precise source code location where the error occurred\n * @returns The constructed ExecutionError instance\n *\n * @remarks\n * Serves as a foundation for custom error types in the application.\n * It enhances the native Error object by adding JSON serialization capabilities\n * and source code location information, allowing for better error reporting,\n * debugging, and troubleshooting. The location tracking feature helps pinpoint\n * exactly where in the codebase an error originated.\n *\n * @example\n * ```ts\n * // Creating a basic execution error with location information\n * const error = new ExecutionError(\n * 'Failed to process data',\n * { line: 42, column: 10 }\n * );\n *\n * // The error can be thrown or used in promise rejection\n * throw error;\n * ```\n *\n * @see InvocationLocationType\n *\n * @since 1.0.0\n */\n\nexport class ExecutionError extends Error {\n\n /**\n * Creates a new ExecutionError instance with the specified error message and source code location\n *\n * @param message - The error message describing what went wrong\n *\n * @remarks\n * This constructor initializes both the standard Error message property and the location\n * information that helps pinpoint exactly where in the codebase the error originated. The\n * location parameter follows the InvocationLocationType structure, typically containing\n * line and column information.\n *\n * @example\n * ```ts\n * const error = new ExecutionError(\n * 'Failed to process input data',\n * { line: 42, column: 8 }\n * );\n * ```\n *\n * @since 1.0.0\n */\n\n constructor(message: string) {\n super(message);\n\n // Assign the name of the error\n this.name = 'xJetExecutionError';\n }\n\n /**\n * Converts the error instance to a plain JavaScript object for JSON serialization.\n *\n * @returns A plain object containing all properties of the error.\n *\n * @remarks\n * This method enhances error serialization by ensuring all properties from the error\n * instance are properly included in the resulting JSON representation. The standard\n * `JSON.stringify()` method doesn't properly serialize Error objects by default, as\n * their properties are typically not enumerable.\n *\n * @example\n * ```ts\n * const error = new ExecutionError('Something went wrong');\n * error.code = 'ERR_INVALID_INPUT';\n *\n * // Convert to JSON\n * const serialized = JSON.stringify(error);\n * // Result includes all properties: message, name, stack, code, etc.\n * ```\n *\n * @since 1.0.0\n */\n\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {};\n\n for (const key of Object.keys(this)) {\n const value = this[key as keyof this];\n if(value) json[key] = value;\n }\n\n json.name = this.name;\n json.stack = this.stack;\n json.message = this.message;\n\n return json;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestModel } from '@shared/models/test.model';\nimport type { ContextType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { ContextInterface, DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { Injectable } from '@symlinks/symlinks.module';\nimport { emitStatus } from '@shared/services/emit.service';\nimport { encodeErrorSchema } from '@packets/packets.module';\nimport { DescribeModel } from '@shared/models/describe.model';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { MessageType } from '@messages/constants/report.constant';\n\n/**\n * Manages the state of test suites within the testing framework, tracking the hierarchy of describe blocks and test cases.\n * Implemented as a singleton to ensure a single source of truth for the test suite structure.\n *\n * @template TestModel - The model type representing individual test cases\n * @template FunctionType - The function type for describe block implementations\n * @template DescribeModel - The model type representing test suite describe blocks\n * @template DescribeOptionsInterface - Configuration options for describe blocks\n *\n * @throws Error - If you attempt to instantiate this class directly instead of using getInstance()\n *\n * @remarks\n * The singleton pattern ensures that all test registration operations work with the same\n * state instance, properly maintaining the hierarchical structure of tests.\n * Use the static getInstance() method to access the singleton instance.\n *\n * @example\n * ```ts\n * // Get the singleton instance\n * const suiteState = SuiteState.getInstance();\n *\n * // Add a describe block\n * suiteState.addDescribe('My test suite', () => {\n * // Test suite implementation\n * }, { only: true });\n *\n * // Add a test case to the current describe block\n * suiteState.addTest(new TestModel('should work', () => {}, { skip: false }));\n * ```\n *\n * @see TestModel\n * @see DescribeModel\n *\n * @since 1.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class SuiteState {\n /**\n * Tracks whether any test or describe block has the 'only' flag set\n *\n * @since 1.0.0\n */\n\n private onlyMode = false;\n\n /**\n * Reference to the currently active describe block in the test hierarchy\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n private currentDescribe: DescribeModel;\n\n /**\n * Reference to the test currently being defined or executed\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n private currentTest?: TestModel;\n\n /**\n * Suite has at least one test\n * @since 1.0.0\n */\n\n private hasTests = false;\n\n /**\n * The top-level describe block that contains all tests and nested describe blocks\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n private readonly rootDescribe: DescribeModel;\n\n /**\n * Array of regular expressions used for filtering test paths\n *\n * @remarks\n * This array stores regular expressions created from filter strings specified in runtime configuration.\n * Used to determine which tests should be executed when filtering is enabled.\n *\n * @see SuiteState.matchesFilter - Method that uses these regex patterns for test filtering\n * @since 1.0.0\n */\n\n private readonly filterRegexChain: Array<RegExp> = [];\n\n /**\n * Creates a new instance of the class with a root describe block\n *\n * @internal\n * @since 1.0.0\n */\n\n constructor() {\n this.rootDescribe = new DescribeModel();\n this.currentDescribe = this.rootDescribe;\n\n if (Array.isArray(__XJET?.runtime.filter) && __XJET.runtime.filter.length > 0) {\n this.onlyMode = true;\n this.filterRegexChain = __XJET.runtime.filter.map(\n (part: string) => new RegExp(`^${ part }$`)\n );\n }\n }\n\n /**\n * Checks if a test path matches the provided regular expression filter patterns\n *\n * This method compares a test's full path (including ancestry and description) against one or more\n * regular expression patterns to determine if the test should be included in execution.\n *\n * @param path - Array of path segments representing test ancestry and description\n * @param filter - Array of RegExp objects to test against the path\n * @returns Boolean indicating whether the path matches the filter patterns\n *\n * @throws Error - When invalid regular expressions are provided\n *\n * @remarks\n * The method aligns the filter from the end of the path, allowing partial matching of nested test structures.\n * This is particularly useful for selecting specific test cases within a larger test hierarchy.\n *\n * @example\n * ```ts\n * // Match tests with description containing \"login\"\n * const matches = SuiteState.matchesFilter(\n * ['Auth', 'User', 'should handle login correctly'],\n * [/login/i]\n * );\n * // Returns: true\n *\n * // Match specific test path structure\n * const matches = SuiteState.matchesFilter(\n * ['API', 'GET', 'should return 200 status'],\n * [/API/, /GET/, /status/]\n * );\n * // Returns: true\n * ```\n *\n * @see filterChain - String-based alternative for exact matching\n * @see addTest - Method that uses matchesFilter to determine which tests to run\n *\n * @since 1.0.0\n */\n\n static matchesFilter(path: string[], filter: RegExp[]): boolean {\n if (filter.length > path.length) return false;\n\n // Align from the end of the path\n const offset = path.length - filter.length;\n\n return filter.every((re, i) => re.test(path[offset + i]));\n }\n\n /**\n * Indicates whether the test suite is running in \"only\" mode\n *\n * @returns True if only specifically marked tests should run\n *\n * @since 1.0.0\n */\n\n get isOnlyMode(): boolean {\n return this.onlyMode;\n }\n\n /**\n * Gets the root describe block of the test suite\n *\n * @returns The top-level describe block\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n get root(): DescribeModel {\n return this.rootDescribe;\n }\n\n /**\n * Gets the current describe block being defined\n *\n * @returns The active describe block\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n get describe(): DescribeModel {\n return this.currentDescribe;\n }\n\n /**\n * Gets the test currently being defined or executed\n *\n * @returns The current test or null if no test is active\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n get test(): TestModel | undefined {\n return this.currentTest;\n }\n\n /**\n * Sets the current test being defined or executed\n *\n * @param test - The test to set as current\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n set test(test: TestModel | undefined) {\n this.currentTest = test;\n }\n\n /**\n * Executes the entire test suite from the root describe block\n *\n * @param context - The execution context containing runtime information\n *\n * @throws Error - When test execution fails, the error is encoded and dispatched\n *\n * @remarks\n * This method initiates the test execution flow by calling run() on the root describe block\n * and emits an END status notification when all tests complete successfully. If an error\n * occurs during execution, it's captured, encoded, and dispatched through the error schema.\n *\n * @example\n * ```ts\n * const suiteState = SuiteState.getInstance();\n * await suiteState.run({\n * timeout: 5000,\n * currentPath: '/tests',\n * skipAfterFailure: true\n * });\n * ```\n *\n * @see emitStatus\n * @see DescribeModel\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<ContextInterface>): Promise<void> {\n try {\n const time = Date.now();\n emitStatus(MessageType.StartSuite);\n if (!this.hasTests)\n throw new ExecutionError('Your test suite must contain at least one test');\n\n await this.root.run(context);\n emitStatus(MessageType.EndSuite, { duration: Date.now() - time });\n } catch (e) {\n dispatch(\n encodeErrorSchema(<Error>e, __XJET.runtime.suiteId, __XJET.runtime.runnerId)\n );\n } finally {\n xJet.restoreAllMocks();\n }\n }\n\n /**\n * Adds a new describe block to the test suite hierarchy\n *\n * @param description - The textual description of the describe block\n * @param describeFn - The function containing the tests and nested describes\n * @param flags - Configuration options for the describe block\n * @param describeArgs - Arguments to pass to the describe function\n *\n * @throws Error - If the describe function throws any exceptions\n *\n * @remarks\n * This method temporarily changes the current describe context while executing\n * the describeFn, then restores it afterward, ensuring proper nesting of test blocks.\n * If the 'only' flag is set, it enables only-mode for the entire test suite.\n *\n * @example\n * ```ts\n * suiteState.addDescribe(\n * 'my test group',\n * () => {\n * // test definitions here\n * },\n * { only: true }\n * );\n * ```\n *\n * @see FunctionType\n * @see DescribeModel\n * @see DescribeOptionsInterface\n *\n * @since 1.0.0\n */\n\n addDescribe(description: string, describeFn: FunctionType, flags: DescribeOptionsInterface = {}, describeArgs: Array<unknown> = []): void {\n const options = { skip: false, only: false, ...flags };\n if (options.only) {\n this.onlyMode = true;\n }\n\n if (this.filterRegexChain.length > 0) {\n const fullPath = [\n ...this.currentDescribe.ancestry,\n this.currentDescribe.description,\n description\n ];\n\n if (SuiteState.matchesFilter(fullPath, this.filterRegexChain)) {\n options.only = true;\n }\n }\n\n const newDescribe = new DescribeModel(description, options);\n this.currentDescribe.addDescribe(newDescribe);\n const previousDescribe = this.currentDescribe;\n this.currentDescribe = newDescribe;\n\n try {\n describeFn.apply({}, describeArgs);\n } finally {\n this.currentDescribe = previousDescribe;\n }\n }\n\n /**\n * Adds a test to the current describe block\n *\n * @param test - The test model to add\n *\n * @remarks\n * If the test has the 'only' option set, it enables only-mode for the entire test suite.\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n addTest(test: TestModel): void {\n // Mark the suite as having at least one test\n this.hasTests = true;\n\n if (test.options.only) this.onlyMode = true;\n this.currentDescribe.addTest(test);\n\n if (this.filterRegexChain.length > 0) {\n const fullPath = [ ...test.ancestry, test.description ];\n\n if (SuiteState.matchesFilter(fullPath, this.filterRegexChain)) {\n test.options.only = true;\n }\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestModel } from '@shared/models/test.model';\nimport type { DescribeModel } from '@shared/models/describe.model';\n\n/**\n * Imports\n */\n\nimport { serialize } from '@remotex-labs/xjet-expect';\nimport { encodePacket } from '@packets/packets.module';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { LogLevel } from '@messages/constants/report.constant';\nimport { getInvocationLocation } from '@components/location.component';\nimport { PacketKind } from '@packets/constants/packet-schema.constants';\n\n/**\n * Creates a logging function that formats and dispatches log messages with timestamps\n *\n * @template T - Console method type that determines the log level\n * @param type - The type of console method (log, info, warn, error) to create a handler for\n * @returns A function that accepts any number of arguments, formats them, and dispatches a log event\n *\n * @throws TypeError - When invalid arguments are provided to the returned function\n *\n * @remarks\n * This function acts as a factory for creating specialized logging handlers. Each handler:\n * - Timestamps the log entry with ISO format\n * - Formats all arguments into string representations\n * - Dispatches the log event with the appropriate log level\n * - Maintains a consistent format for all log messages\n *\n * @example\n * ```ts\n * const logInfo = createLogHandler('info');\n * logInfo('User', user.id, 'logged in successfully');\n * // Dispatches a log event with level: 'INFO', formatted arguments, and timestamp\n * ```\n *\n * @see formatValue\n * @see dispatch\n * @see SchemaType\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport function createLogHandler(type: keyof typeof LogLevel) {\n return function (...args: unknown[]): void {\n let parent: TestModel | DescribeModel | undefined = inject(SuiteState).test;\n if (!parent) {\n parent = inject(SuiteState).describe;\n }\n\n const context = [ ...parent?.ancestry ?? [], parent?.description ].join(',');\n\n // Format arguments for the description\n const formattedArgs = args.map((data: unknown) => serialize(data).join('\\n')).join(' ');\n const location = getInvocationLocation();\n\n // Dispatch log event\n dispatch(encodePacket(PacketKind.Log, {\n level: LogLevel[type],\n message: formattedArgs,\n ancestry: context ?? '',\n invocation: location\n }));\n };\n}\n\n/**\n * Standard log level function for general purpose logging\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const log = createLogHandler('Info');\n\n/**\n * Informational log function for highlighting noteworthy application events\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const info = createLogHandler('Info');\n\n/**\n * Warning log function for potential issues that aren't errors\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const warn = createLogHandler('Warn');\n\n/**\n * Error log function for reporting application errors and exceptions\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const error = createLogHandler('Error');\n\n/**\n * Debug log function for detailed diagnostic information\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const debug = createLogHandler('Debug');\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketInvocationInterface } from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Imports\n */\n\nimport { parseErrorStack } from '@remotex-labs/xmap/parser.component';\n\n/**\n * Retrieves the location in the source code where this function was invoked.\n *\n * @param position - The stack frame index to inspect (default is 3). This allows skipping\n * internal frames to reach the actual caller.\n * @returns A {@link PacketInvocationInterface} containing `line`, `column`, and `source` file\n * of the invocation, or `undefined` if the location could not be determined.\n *\n * @remarks\n * This function generates a new `Error` to capture the stack trace, parses it using\n * {@link parseErrorStack}, and returns the requested frame as a structured object.\n * It is useful for logging or reporting the exact location of a call within test suites\n * or framework code.\n *\n * @see parseErrorStack\n * @see PacketInvocationInterface\n *\n * @since 1.0.0\n */\n\nexport function getInvocationLocation(position: number = 2): PacketInvocationInterface | undefined {\n const errorObject = parseErrorStack(new Error());\n const stack = errorObject.stack[position];\n\n if (stack?.line && stack?.column && stack?.fileName) {\n return {\n line: stack.line!,\n column: stack.column!,\n source: stack.fileName!\n };\n }\n\n return undefined;\n}\n\n/**\n * Returns a native-style stack trace string,\n * trimmed to start at the specified frame index.\n *\n * @remarks\n * The first line (error name/message) is preserved,\n * while the following lines are sliced starting from `position`.\n *\n * @param position - Index of the first stack frame to include.\n * Defaults to `2` to skip this helper and its caller.\n *\n * @returns A string identical in format to `Error.stack`,\n * or an empty string if the stack is unavailable.\n *\n * @example\n * ```ts\n * console.log(getTrimmedStackString(2));\n * ```\n *\n * @since 3.1.0\n */\n\nexport function getTrimmedStackString(position: number = 2): string {\n const err = new Error();\n if (!err.stack) return '';\n\n const lines = err.stack.split('\\n');\n const frames = lines.slice(position + 1);\n\n return frames.join('\\n');\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { DeepSearchInterface } from '@shared/components/interfaces/object.interface';\n\n/**\n * Recursively searches for a specific element within an object or its nested properties.\n *\n * @param target - The object to search within.\n * @param element - The value to find within the target object or its nested properties.\n * @param key - Optional specific key to search for within the target object.\n * @param maxDepth - Maximum recursion depth to prevent infinite loops, defaults to 3.\n * @returns A {@link DeepSearchInterface} object containing parent and key if found, or null if not found.\n *\n * @remarks\n * This utility performs a depth-first search through an object's properties to locate a specific value\n * or a property with a specific key. It maintains a set of visited objects to prevent circular reference issues.\n *\n * The search process:\n * - Tracks visited objects to avoid circular references\n * - Searches by exact reference equality for the element\n * - Handles errors during property access\n * - Limits search depth to prevent stack overflow\n * - Can find elements by exact key name (when the `key` parameter is provided)\n *\n * @example\n * ```ts\n * const obj = {\n * a: 1,\n * b: {\n * c: 'test',\n * d: [1, 2, { e: 'target' }]\n * }\n * };\n *\n * // Find by value\n * const result = deepSearchObject(obj, 'target');\n * // result: { parent: { e: 'target' }, key: 'e' }\n *\n * // Find by key name\n * const byKey = deepSearchObject(obj, null, 'c');\n * // byKey: { parent: { c: 'test', d: [...] }, key: 'c' }\n * ```\n *\n * @see DeepSearchInterface\n * @since 1.0.0\n */\n\nexport function deepSearchObject(\n target: Record<string | symbol, unknown>, element: unknown, key?: string | symbol, maxDepth: number = 3\n): DeepSearchInterface | null {\n const visited = new WeakSet<object>();\n\n function search(target: Record<string | symbol, unknown>, depth: number): DeepSearchInterface | null {\n if (depth > maxDepth || target == null || (typeof target !== 'object' && typeof target !== 'function')) return null;\n if (visited.has(target)) return null;\n visited.add(target);\n\n if (key && key in target) return { parent: target, key };\n for (const [ prop, value ] of Object.entries(target)) {\n if (Object.is(value, element)) return { parent: target, key: prop };\n if (value && (typeof value === 'object' || typeof value === 'function')) {\n const found = search(value as Record<string | symbol, unknown>, depth + 1);\n if (found) return found;\n }\n }\n\n return null;\n }\n\n return search(target, 0);\n}\n\n/**\n * Resolves property references that may be affected by ESBuild's `__toESM` transformation.\n *\n * @remarks\n * This function handles a specific issue with ESBuild's module transformation where Node.js\n * built-in modules (like 'fs', 'http', etc.) are wrapped with getter descriptors that aren't\n * configurable. This causes problems when trying to mock or modify these modules in testing.\n *\n * When ESBuild transforms CommonJS modules to ESM, it creates non-configurable getter properties\n * on the module object. This function detects such cases and returns a reference to the original\n * underlying object instead, making the property accessible for mocking or modification.\n *\n * @param parent - The object containing the property to resolve\n * @param key - The property name or symbol to resolve\n * @returns A {@link DeepSearchInterface} pointing to either the original object or the\n * underlying object in case of non-configurable ESBuild transformations\n *\n * @example\n * ```ts\n * // When working with an ESBuild transformed fs module\n * import * as fs from 'fs';\n *\n * // Normal access would use a non-configurable getter\n * // Making it impossible to mock\n * const originalRef = { parent: fs, key: 'readFileSync' };\n *\n * // This function resolves to the underlying object\n * const mockableRef = getOwnProperty(fs, 'readFileSync');\n * // Now we can mock it: mockableRef.parent[mockableRef.key] = mockFn;\n * ```\n *\n * @since 1.2.2\n */\n\nexport function getOwnProperty(parent: Record<string | symbol, unknown>, key: string | symbol): DeepSearchInterface {\n const method = Reflect.get(parent, key);\n const descriptor = Object.getOwnPropertyDescriptor(parent, key);\n\n if (descriptor?.get && !descriptor.configurable) {\n if ('default' in parent && Reflect.get(<object> parent.default, key) === method) {\n return { parent: <Record<string, unknown>> parent.default, key };\n }\n }\n\n return { parent, key };\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConstructorLikeType, FunctionLikeType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { MockableFunctionInterface, PartialResolvedType } from '@shared/mock/interfaces/fn-mock.interface';\n\n/**\n * Imports\n */\n\nimport { MockState } from '@shared/states/mock.state';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { deepSearchObject, getOwnProperty } from '@shared/components/object.component';\n\n/**\n * Creates a mock for an object property using property descriptors.\n *\n * @template T - The type of the target object containing the property to mock\n *\n * @param target - The object containing the property to mock\n * @param key - The name of the property to mock\n * @returns A {@link MockState} instance that tracks interactions with the property\n *\n * @remarks\n * The `mockDescriptorProperty` function replaces a property on a target object with a getter/setter\n * that intercepts access to that property. This allows for monitoring and controlling property\n * access during tests. The original property can be restored later through the mock's\n * restore capability.\n *\n * Responsibilities:\n * - Intercepting property access via custom property descriptors\n * - Capturing the original property value and descriptor\n * - Creating a {@link MockState} instance to track interactions\n * - Supporting property restoration through the {@link MockState.mockRestore} method\n * - Maintaining references in the global {@link MockState.mocks} registry\n *\n * @example\n * ```ts\n * // Mock a property on an object\n * const obj = { value: 42 };\n * const mockValue = mockDescriptorProperty(obj, 'value');\n * ```\n *\n * @see MockState\n * @since 1.2.0\n */\n\nexport function mockDescriptorProperty<T extends object>(target: T, key: string | number | symbol): MockState {\n const original = Reflect.get(<object> target, key);\n const originalDescriptor = Object.getOwnPropertyDescriptor(target, key) || {};\n const mockInstance = new MockState(() => original, () => {\n Reflect.set(target, key, originalDescriptor.value);\n Object.defineProperty(target, key, originalDescriptor);\n }, `xJet.spyOn(${ String(key) })`);\n\n MockState.mocks.add(new WeakRef(mockInstance));\n Object.defineProperty(target, key, {\n get() {\n return mockInstance.apply(this, []);\n },\n set(value: unknown) {\n mockInstance.mockImplementation(() => value);\n\n return mockInstance.apply(this, [ value ]);\n }\n });\n\n return mockInstance;\n}\n\n/**\n * Creates a mock function interface with the specified implementation and optional restore function.\n *\n * @template ReturnType - The return type of the mocked function.\n * @template Args - The argument type of the mocked function. Defaults to an array of unknown values.\n * @template Context - The context type that the mocked function binds to.\n *\n * @param implementation - An optional implementation of the mocked function.\n * @param restore - An optional restore function used to reset the mock.\n * @returns A mocked function interface with the specified behaviors.\n *\n * @remarks\n * The `fnImplementation` function creates a mock function handler, typically used in testing scenarios.\n * It transforms regular functions into mockable objects that can be monitored and controlled.\n *\n * Responsibilities:\n * - Creating mock functions with custom implementations\n * - Supporting restore functionality for resetting mocks\n * - Providing type-safe mock interfaces via {@link MockableFunctionInterface}\n * - Integrating with the {@link MockState} system\n *\n * @example\n * ```ts\n * // Creating a mock with a custom implementation\n * const mock = xJet.fn((x: number) => x * 2);\n * console.log(mock(5)); // 10\n *\n * // Creating a mock with a restore function\n * const mockWithRestore = xJet.fn(undefined, () => { console.log('Restored!'); });\n * mockWithRestore.restore(); // \"Restored!\"\n * ```\n *\n * @see MockState\n * @see MockableFunctionInterface\n * @see FunctionLikeType\n *\n * @since 1.2.0\n */\n\nexport function fnImplementation<ReturnType, Args extends Array<unknown>, Context>(\n implementation?: FunctionLikeType<ReturnType, Args, Context>,\n restore?: () => FunctionLikeType<ReturnType, Args, Context> | void\n): MockableFunctionInterface<FunctionLikeType<ReturnType, Args, Context>> {\n return <MockableFunctionInterface<FunctionLikeType<ReturnType, Args, Context>>>\n new MockState(implementation, restore, 'xJet.fn()');\n}\n\n/**\n * Creates a mock implementation of the provided class constructor.\n *\n * @param method - The class constructor to mock\n * @param implementation - Optional custom implementation of the mocked constructor\n * @returns The mock state associated with the mocked constructor\n *\n * @remarks\n * This overload of the mockImplementation function is specifically designed for mocking class constructors.\n * It allows for replacing a class implementation during testing while tracking instantiation.\n *\n * The implementation function can return a partial instance of the class, which will be used\n * as the constructed object when the mock is called with 'new'.\n *\n * @example\n * ```ts\n * class User {\n * name: string;\n * age: number;\n * constructor (name: string, age: number) {\n * this.name = name;\n * this.age = age;\n * }\n * }\n *\n * const MockUser = mockImplementation(User, (name, age) => ({ name, age: age + 1 }));\n * const user = new MockUser('Alice', 30); // user.age === 31\n * MockUser.verify.called(); // passes\n * ```\n *\n * @since 1.2.2\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mockImplementation<F extends abstract new (...args: any) => any>(\n method: F,\n implementation?: (...args: ConstructorParameters<F>) => PartialResolvedType<InstanceType<F>>\n): MockState<(...args: ConstructorParameters<F>) => PartialResolvedType<InstanceType<F>>>;\n\n/**\n * Creates a mock implementation of the provided function.\n *\n * @param method - The function to mock\n * @param implementation - Optional custom implementation that returns a partial result\n * @returns The mock state associated with the mocked function\n *\n * @remarks\n * This overload of the mockImplementation function allows for providing an implementation\n * that returns a partial result object. This is particularly useful when mocking functions\n * that return complex objects where only specific properties are relevant for testing.\n *\n * The implementation preserves the 'this' context from the original function, allowing\n * for proper method mocking on objects.\n *\n * @example\n * ```ts\n * interface User {\n * id: number;\n * name: string;\n * email: string;\n * }\n *\n * function getUser(id: number): User {\n * // real implementation\n * return { id, name: 'Real User', email: 'user@example.com' };\n * }\n *\n * const mockGetUser = mockImplementation(getUser, (id) => ({ id, name: 'Mock User' }));\n * const user = mockGetUser(123); // { id: 123, name: 'Mock User' }\n * ```\n *\n * @since 1.2.2\n */\n\nexport function mockImplementation<F extends FunctionType>(\n method: F,\n implementation?: (...args: Parameters<F>) => PartialResolvedType<ReturnType<F>>\n): MockState<(this: ThisParameterType<F>, ...args: Parameters<F>) => PartialResolvedType<ReturnType<F>>>;\n\n/**\n * Creates a mock for an element with an optional custom implementation.\n *\n * @template Element - The type of the element being mocked\n *\n * @param item - The element to mock\n * @param implementation - Optional custom implementation to replace the original element's behavior\n * @returns A {@link MockState} instance that controls and tracks the mock\n *\n * @remarks\n * The `mockImplementation` function creates a new {@link MockState} instance that wraps\n * around the provided element, allowing you to observe interactions with it and optionally\n * override its behavior. This is useful for isolating components during testing by\n * replacing their dependencies with controlled mocks.\n *\n * Responsibilities:\n * - Creating a trackable mock from any element\n * - Supporting custom implementation substitution\n * - Maintaining type safety between the original and mocked elements\n * - Enabling interaction tracking and verification capabilities\n * - Providing a fluent API for configuring mock behavior\n *\n * @example\n * ```ts\n * // Mock a simple value like export const testValue = 'original value'\n * const mockValue = xJet.mock(testValue);\n * mockValue.mockReturnValue(\"mocked value\");\n *\n * // Mock a function\n * const originalFn = (name: string) => `Hello, ${name}!`;\n * const mockedFn = xJet.mock(originalFn);\n *\n * // Configure custom implementation\n * mockedFn.mockImplementation((name: string) => `Hi, ${name}!`);\n *\n * test ('uses mocked function', () => {\n * const result = xJet.mock(testValue);\n * expect(result).toBe('Hi, World!');\n * expect(mockedFn).toHaveBeenCalledWith('World');\n * });\n * ```\n *\n * @see MockState\n * @see FunctionLikeType\n *\n * @since 1.2.0\n */\n\nexport function mockImplementation<Element = unknown>(\n item: Element,\n implementation?: () => Element\n): MockState<() => Element>;\n\n/**\n * Creates a mock for an item with an optional custom implementation.\n *\n * @param element - The element to mock\n * @param implementation - Optional custom implementation to replace the original item's behavior\n * @returns A {@link MockState} instance that controls and tracks the mock\n *\n * @remarks\n * The `mockImplementation` function creates a new {@link MockState} instance that wraps\n * around the provided item, allowing you to monitor interactions with it and optionally\n * override its implementation. This is particularly useful for testing components that\n * depend on external objects or functions by providing controlled behavior during tests.\n *\n * Responsibilities:\n * - Creating a trackable mock from any item (function, constructor, or value)\n * - Supporting custom implementation override capability\n * - Handling special cases for constructors with non-writable prototypes\n * - Enabling call tracking and verification functionality\n * - Maintaining the original reference in the parent object for restoration\n *\n * @example\n * ```ts\n * // Mock a function\n * const fetchData = async () => ({ id: 1, name: 'Test' });\n * const mockedFetch = xJet.mock(fetchData);\n *\n * // Mock with custom implementation\n * const mockedFetchCustom = xJet.mock(fetchData, async () => {\n * return { id: 2, name: 'Custom Test' };\n * });\n * ```\n *\n * @see MockState\n * @see FunctionLikeType\n * @see ConstructorLikeType\n *\n * @since 1.2.0\n */\n\nexport function mockImplementation(element: unknown, implementation?: FunctionType): MockState {\n if (!element) throw new ExecutionError('xJet.mock element is not defined');\n if (typeof element === 'function' && (element as MockState).xJetMock) return <MockState> element;\n\n const findObject = deepSearchObject(globalThis, element, (<FunctionType> element)?.name);\n if (!findObject) {\n throw new ExecutionError(\n 'Unable to mock this item: it was not found in any global object.\\n' +\n 'If you are trying to mock a Proxy object, please use xJet.spyOn() instead.'\n );\n }\n\n const { parent, key } = getOwnProperty(findObject.parent, findObject.key);\n const method = Reflect.get(parent, key);\n\n if (typeof method === 'function' && method.prototype && !Object.getOwnPropertyDescriptor(method, 'prototype')?.writable) {\n const mock = new MockState(\n (...args: Array<unknown>) => {\n return new (method as ConstructorLikeType<unknown, Array<unknown>>)(...args);\n },\n () => {\n Reflect.set(parent, key, method);\n }\n );\n\n Reflect.set(parent, key, mock);\n MockState.mocks.add(new WeakRef(mock));\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n }\n\n if (typeof method === 'function') {\n const mock = new MockState(<FunctionType> method, () => {\n Reflect.set(parent, key, method);\n });\n\n Reflect.set(parent, key, mock);\n MockState.mocks.add(new WeakRef(mock));\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n }\n\n const mock = mockDescriptorProperty(parent, key);\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PartialResolvedType } from '@shared/mock/interfaces/fn-mock.interface';\nimport type { ConstructorLikeType, FunctionLikeType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { MockProxyInterface, MockProxyStateInterface } from '@shared/mock/interfaces/spy-mock.interface';\n\n/**\n * Imports\n */\n\nimport { MockState } from '@shared/states/mock.state';\nimport { mockDescriptorProperty } from '@shared/mock/fn.mock';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { deepSearchObject, getOwnProperty } from '@shared/components/object.component';\n\n/**\n * Checks if a property on an object is provided via a proxy mechanism rather than directly defined.\n *\n * @template T - The type of object being checked\n *\n * @param obj - The object to inspect\n * @param key - The property key to check on the object\n * @returns `true` if the property is provided by a proxy, `false` if directly defined\n *\n * @remarks\n * This function determines whether a property on an object is being provided through\n * a proxy mechanism (like a Proxy object or getter) rather than being directly defined\n * on the object itself. It works by checking if the key doesn't exist in the object's\n * own properties while still returning a non-undefined value when accessed.\n *\n * This is useful for:\n * - Detecting dynamically created properties\n * - Identifying properties provided via getters or proxies\n * - Distinguishing between direct properties and inherited/proxied ones\n *\n * @example\n * ```ts\n * // Regular object with direct property\n * const directObj = { name: 'Test' };\n * console.log(isProxyProperty(directObj, 'name')); // false\n *\n * // Object with proxy property\n * const handler = {\n * get(target, prop) {\n * if (prop === 'dynamic') return 'This is dynamic';\n * return target[prop];\n * }\n * };\n * const proxyObj = new Proxy({}, handler);\n * console.log(isProxyProperty(proxyObj, 'dynamic')); // true\n * ```\n *\n * @since 1.2.0\n */\n\nexport function isProxyProperty<T extends object>(obj: T, key: keyof T): boolean {\n return !(key in obj) && Reflect.get(obj, key) !== undefined;\n}\n\n/**\n * Determines if a value is a mock proxy created by the mocking system.\n *\n * @param value - The value to check\n * @returns `true` if the value is a mock proxy, `false` otherwise\n *\n * @remarks\n * This function checks if an object has the internal `__isMockProxy__` symbol property\n * which is added to all mock proxy objects created by the mocking framework.\n *\n * Mock proxies are specialized proxy objects that intercept property access\n * and method calls while providing mocking capabilities.\n *\n * @example\n * ```ts\n * const regularObject = { name: 'Test' };\n * const mockObject = createMock({ name: 'Test' });\n *\n * isMockProxy(regularObject); // false\n * isMockProxy(mockObject); // true\n * ```\n *\n * @since 1.2.2\n */\n\nexport function isMockProxy(value: Record<symbol, unknown>): boolean {\n return (value && typeof value === 'object' && '__isMockProxy__' in value);\n}\n\n/**\n * Creates a mock proxy that intercepts property access on an object.\n *\n * @template T - The type of the target object being proxied\n * @param target - The object to be proxied\n * @returns A MockProxyInterface that intercepts property access on the target\n *\n * @remarks\n * This function creates a proxy around an object that allows for interception\n * and customization of property access. The proxy maintains an internal state\n * that tracks mocked properties and provides mechanisms for customizing getter behavior.\n *\n * The proxy implements special properties:\n * - `__isMockProxy__`: Used to identify mock proxy objects\n * - `__MockMap__`: Provides access to the internal state for managing mocks\n *\n * Property access behavior:\n * 1. First checks if a custom getter is defined and uses it if available\n * 2. Then checks if the property has a specific mock implementation\n * 3. Falls back to the original property on the target object\n *\n * @example\n * ```ts\n * const user = { name: 'John', getAge: () => 30 };\n * const mockUser = createMockProxy(user);\n *\n * // Access original property\n * console.log(mockUser.name); // \"John\"\n *\n * // Add a mock for a property\n * const mockMap = mockUser.__MockMap__;\n * mockMap.mocks.set('getAge', () => 25);\n *\n * // Now returns the mock implementation\n * console.log(mockUser.getAge()); // 25\n * ```\n *\n * @since 1.2.2\n */\n\nexport function createMockProxy<T extends object>(target: T): MockProxyInterface {\n const state: MockProxyStateInterface = {\n mocks: new Map(),\n customGetter: null\n };\n\n const handler: ProxyHandler<T> = {\n get(_target, prop, receiver) {\n if (prop === '__isMockProxy__') return true;\n if (prop === '__MockMap__') return state;\n\n if (state.customGetter) {\n return state.customGetter(target, prop, receiver);\n }\n\n if (state.mocks.has(prop)) {\n return state.mocks.get(prop);\n }\n\n return Reflect.get(target, prop, receiver);\n }\n };\n\n return new Proxy({}, handler);\n}\n\n/**\n * Creates a spy on a property access for a proxied object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property to spy on\n *\n * @param target - The proxy object containing the property to spy on\n * @param prop - The name of the property to spy on\n * @returns A MockState object wrapping the property access\n *\n * @remarks\n * This specialized spy function is designed to work with properties accessed through proxy objects.\n * It handles the complexities of intercepting property access in proxied objects by:\n *\n * 1. Locating the proxy object in the global scope if needed\n * 2. Converting a normal object to a mock proxy if it isn't already one\n * 3. Setting up a spy on the property get operation\n *\n * The function ensures proper cleanup by providing a cleanup function that removes\n * the spy from the proxy's internal mock map when the spy is restored.\n *\n * @throws Error - When the target object cannot be found in the global scope\n *\n * @example\n * ```ts\n * // With an existing proxy\n * const proxyObj = createMockProxy({ getData: () => 'data' });\n * const spy = spyOnProxyGet(proxyObj, 'getData');\n *\n * proxyObj.getData(); // Spy records this call\n * spy.verify.called(); // Passes\n *\n * // With a normal object (will be converted to proxy)\n * const obj = { getValue: () => 42 };\n * const valueSpy = spyOnProxyGet(obj, 'getValue');\n *\n * obj.getValue(); // Spy records this call\n * valueSpy.verify.called(); // Passes\n * ```\n *\n * @since 1.2.2\n */\n\nexport function spyOnProxyGet<T extends Record<string | symbol, unknown>, K extends keyof T>(target: T, prop: K): MockState {\n const found = deepSearchObject(globalThis, target);\n if (!found) {\n throw new Error('xJet.spyOn item is not part of any global object');\n }\n\n if (!isMockProxy(target)) {\n const { parent, key } = getOwnProperty(found.parent, found.key);\n const method = Reflect.get(parent, key);\n\n Reflect.set(parent, key, createMockProxy(method as object));\n target = Reflect.get(parent, key) as T;\n }\n\n const proxy = target as MockProxyInterface;\n const mockState = new MockState(<FunctionType> target[prop], () => {\n proxy.__MockMap__?.mocks.delete(prop);\n }, 'xJet.spyOn(Proxy#get)');\n\n proxy.__MockMap__?.mocks.set(prop, mockState);\n\n return mockState;\n}\n\n/**\n * Creates a spy on a method or property of an object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property or method to spy on\n *\n * @param target - The object containing the method or property to spy on\n * @param key - The name of the method or property to spy on\n * @returns A MockState object wrapping the original method or property\n *\n * @remarks\n * This function creates a spy that wraps around an existing method or property on an object.\n * The spy tracks all calls to the method or access to the property while still executing the original functionality.\n *\n * - For methods: The spy preserves the original `this` context and passes all arguments to the original method\n * - For properties: The spy intercepts property access and returns the original value\n *\n * @example\n * ```ts\n * // Spying on a method\n * const user = {\n * getName: (prefix: string) => prefix + ' John'\n * };\n * const spy = xJet.spyOn(user, 'getName');\n *\n * user.getName('Mr.'); // Returns \"Mr. John\"\n * ```\n *\n * @since 1.0.0\n */\n\nexport function spyOnImplementation<T extends object, K extends keyof T>(target: T, key: K):\n T[K] extends FunctionType ?\n MockState<(\n this: ThisParameterType<T[K]>, ...args: Parameters<T[K]>\n ) => PartialResolvedType<ReturnType<T[K]>>>\n : MockState<() => T[K]>;\n\n/**\n * Creates a spy on a method or property of an object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property or method to spy on\n *\n * @param target - The object containing the method or property to spy on\n * @param prop - The name of the method or property to spy on\n * @returns A MockState object wrapping the original method or property\n *\n * @remarks\n * This function creates a spy that wraps around an existing method or property on an object.\n * The spy tracks all calls to the method or access to the property while still executing the original functionality.\n *\n * - For methods: The spy preserves the original behavior while monitoring calls\n * - For properties: The spy intercepts property access via descriptor methods\n * - For class constructors: Special handling ensures proper constructor behavior\n *\n * The implementation handles various edge cases:\n * - Properties accessed through proxies\n * - Constructor functions with non-writable prototypes\n * - Properties that may exist in the prototype chain\n *\n * @throws ExecutionError - When:\n * - Target is not an object or function\n * - Property key is null\n * - Property doesn't exist on the target or its prototype chain\n *\n * @example\n * ```ts\n * // Spying on a method\n * const user = {\n * getName: () => { return 'John'; }\n * };\n * const spy = xJet.spyOn(user, 'getName');\n *\n * user.getName(); // Returns \"John\"\n * ```\n *\n * @since 1.0.0\n */\n\nexport function spyOnImplementation<T extends Record<string | symbol, unknown>, K extends keyof T>(target: T, prop: K): MockState {\n if (target == null || (typeof target !== 'object' && typeof target !== 'function'))\n throw new ExecutionError('Target must be an object or function');\n\n if (prop === null)\n throw new ExecutionError('Spied property/method key is required');\n\n let method = <MockState & T[K]> Reflect.get(target, prop);\n if(method?.xJetMock) return method;\n\n if (isProxyProperty(target, prop))\n return spyOnProxyGet(target, <string> prop);\n\n const { parent, key } = getOwnProperty(target, <string> prop);\n if (!(key in parent))\n throw new ExecutionError(`Property/method '${ String(key) }' does not exist on target`);\n\n method = <MockState & T[K]> Reflect.get(parent, prop);\n if (!method) throw new Error(`Property '${ String(key) }' does not exist in the provided object`);\n const descriptor = Object.getOwnPropertyDescriptor(parent, key);\n\n if (typeof method !== 'function' || descriptor?.get)\n return mockDescriptorProperty(parent, key);\n\n let fn: FunctionLikeType = method as FunctionLikeType;\n const protoDesc = Object.getOwnPropertyDescriptor(fn, 'prototype');\n\n if (fn.prototype && protoDesc && !protoDesc.writable) {\n fn = (...args: unknown[]): unknown =>\n new (method as ConstructorLikeType<unknown, unknown[]>)(...args);\n }\n\n const mockState = new MockState(fn, () => {\n Reflect.set(target, key, method);\n }, `xJet.spyOn(${ String(method.name) })`);\n\n MockState.mocks.add(new WeakRef(mockState));\n Reflect.set(parent, key, mockState);\n\n return mockState;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionLikeType } from '@remotex-labs/xjet-expect';\nimport type { TimerInterface } from '@shared/services/interfaces/timer-service.interface';\n\n/**\n * Imports\n */\n\nimport { Injectable, inject } from '@symlinks/services/inject.service';\n\n/**\n * Provides a virtual timer system that mimics native `setTimeout`/`setInterval`\n * while allowing controlled execution for deterministic tests.\n *\n * @remarks\n * This service replaces the global timing functions with fake timers so that\n * time can be manually advanced and callbacks triggered predictably.\n * It is intended for unit testing scenarios where you need full control over\n * asynchronous timing without waiting in real time.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 1000);\n * advanceTimersByTime(1000); // logs 'done' immediately\n * useRealTimers();\n * ```\n *\n * @since 1.1.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class TimerService {\n /**\n * Active timers managed by the fake timer engine.\n * @since 1.1.0\n */\n\n readonly timers = new Map<number, TimerInterface>();\n\n /**\n * Stores original `Date.now` to restore when real timers are re-enabled.\n * @since 1.1.0\n */\n\n readonly originalDateNow = Date.now;\n\n /**\n * Stores original global `setTimeout`.\n * @since 1.1.0\n */\n\n readonly originalSetTimeout = globalThis.setTimeout;\n\n /**\n * Stores original global `setInterval`.\n * @since 1.1.0\n */\n\n readonly originalSetInterval = globalThis.setInterval;\n\n /**\n * Stores original global `clearTimeout`.\n * @since 1.1.0\n */\n\n readonly originalClearTimeout = globalThis.clearTimeout;\n\n /**\n * Stores original global `clearInterval`.\n * @since 1.1.0\n */\n\n readonly originalClearInterval = globalThis.clearInterval;\n\n /**\n * Simulated current timestamp for the fake timers.\n * @since 1.1.0\n */\n\n private now = 0;\n\n /**\n * Incremental id used to register timers uniquely.\n * @since 1.1.0\n */\n\n private nextId = 1;\n\n /**\n * Replaces the global timer functions with in-memory fakes.\n *\n * @remarks\n * After calling this method, any calls to `setTimeout`, `setInterval`,\n * `clearTimeout`, or `clearInterval` will be intercepted and stored in the\n * {@link timers} map instead of scheduling real OS timers.\n * This allows tests to control time progression manually using\n * {@link advanceTimersByTime}, {@link runAllTimers}, or\n * {@link runOnlyPendingTimers}.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * const id = setTimeout(() => console.log('done'), 1000);\n * timerService.advanceTimersByTime(1000); // logs \"done\" immediately\n * ```\n *\n * @since 1.1.0\n */\n\n useFakeTimers(): void {\n const setTimeout = (cb: FunctionLikeType<void>, delay: number = 0, ...args: Array<unknown>): number => {\n const id = this.nextId++;\n this.timers.set(id, { id, callback: cb, time: this.now + delay, interval: null, args: args ?? [] });\n\n return id;\n };\n\n const setInterval = (cb: FunctionLikeType<void>, interval: number = 0): number => {\n const id = this.nextId++;\n this.timers.set(id, { id, callback: cb, time: this.now + interval, interval, args: [] });\n\n return id;\n };\n\n const clearTimeout = (id: number): void => {\n this.timers.delete(id);\n };\n\n\n const clearInterval = (id: number): void => {\n this.timers.delete(id);\n };\n\n const global = <Record<string, unknown>> globalThis;\n global.setTimeout = setTimeout;\n global.setInterval = setInterval;\n global.clearTimeout = clearTimeout;\n global.clearInterval = clearInterval;\n }\n\n /**\n * Restores the original global timer APIs and `Date.now`.\n *\n * @remarks\n * This method undoes the effects of {@link useFakeTimers}, re-binding\n * the native implementations of `setTimeout`, `setInterval`,\n * `clearTimeout`, `clearInterval`, and `Date.now`.\n * After calling this, timers once again behave according to real system\n * time and manual advancement methods such as\n * {@link advanceTimersByTime} no longer apply.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * // ...run tests with controlled time...\n * timerService.useRealTimers(); // restore native timers\n * ```\n *\n * @since 1.1.0\n */\n\n useRealTimers(): void {\n this.timers.clear();\n globalThis.setTimeout = this.originalSetTimeout;\n globalThis.clearTimeout = this.originalClearTimeout;\n globalThis.setInterval = this.originalSetInterval;\n globalThis.clearInterval = this.originalClearInterval;\n Date.now = this.originalDateNow;\n }\n\n /**\n * Clears all active fake timers.\n *\n * @remarks\n * This method removes every timer currently stored in {@link timers},\n * effectively resetting the fake timer state without advancing time.\n * It is useful for cleaning up between tests to ensure no lingering\n * scheduled callbacks remain.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * clearAllTimers(); // removes all scheduled timers\n * advanceTimersByTime(100); // nothing happens\n * ```\n *\n * @since 1.3.0\n */\n\n clearAllTimers(): void {\n this.timers.clear();\n }\n\n /**\n * Advances the simulated clock by a specific number of milliseconds and\n * executes all timers whose scheduled time has elapsed.\n *\n * @remarks\n * Use this method after calling {@link useFakeTimers} to fast-forward the\n * internal clock without waiting in real time.\n * Any `setTimeout` or `setInterval` callbacks scheduled within the\n * advanced period will run immediately in order of their scheduled time.\n *\n * @param ms - The number of milliseconds to move the simulated time forward.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => console.log('done'), 500);\n * timerService.advanceTimersByTime(500); // logs \"done\"\n * ```\n *\n * @since 1.1.0\n */\n\n advanceTimersByTime(ms: number) : void {\n this.now += ms;\n this.runDueTimers();\n }\n\n /**\n * Executes every scheduled timer until none remain.\n *\n * @remarks\n * This method repeatedly advances the simulated clock to the next\n * scheduled timer and runs its callback until the {@link timers} map\n * is empty.\n * It is useful when you want to immediately flush **all** pending\n * `setTimeout` or `setInterval` callbacks regardless of their delay,\n * without specifying a time increment.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n * timerService.runAllTimers(); // logs \"A\" then \"B\"\n * ```\n *\n * @since 1.1.0\n */\n\n runAllTimers(): void {\n while (this.timers.size > 0) {\n this.now = Math.min(...Array.from(this.timers.values()).map(t => t.time));\n this.runDueTimers();\n }\n }\n\n /**\n * Executes only the timers that are currently pending at the time of call,\n * without running any new timers that may be scheduled by those callbacks.\n *\n * @remarks\n * Unlike {@link runAllTimers}, this method captures the set of timers\n * that exist when the method is invoked and restricts execution to that\n * initial set.\n * If any of those timers schedule additional timers while running,\n * the newly scheduled ones will **not** be executed during this call.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n *\n * timerService.runOnlyPendingTimers();\n * // Logs only \"first\" because \"second\" was created afterward.\n * ```\n *\n * @since 1.1.0\n */\n\n runOnlyPendingTimers(): void {\n const pendingTimers = new Set(this.timers.keys());\n\n while (pendingTimers.size > 0) {\n const nextTimerTimes = Array.from(this.timers.values())\n .filter(t => pendingTimers.has(t.id))\n .map(t => t.time);\n\n if (nextTimerTimes.length === 0) break;\n\n this.now = Math.min(...nextTimerTimes);\n this.runDueTimers(pendingTimers);\n\n for (const id of pendingTimers) {\n if (!this.timers.has(id)) pendingTimers.delete(id);\n }\n }\n }\n\n /**\n * Asynchronous equivalent of {@link runAllTimers}.\n *\n * @remarks\n * This method first yields to the event loop to allow any pending promises\n * to resolve before executing all remaining fake timers.\n * It ensures a deterministic sequence when timers and microtasks coexist.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * Promise.resolve().then(() => console.log('microtask'));\n * setTimeout(() => console.log('timer'), 0);\n * await timerService.runAllTimersAsync();\n * // Logs:\n * // microtask\n * // timer\n * ```\n *\n * @since 1.3.0\n */\n\n async runAllTimersAsync(): Promise<void> {\n await Promise.resolve();\n this.runAllTimers();\n }\n\n /**\n * Asynchronous equivalent of {@link runOnlyPendingTimers}.\n *\n * @remarks\n * This method first yields to the event loop to allow any pending promises\n * to resolve before executing only currently pending fake timers.\n * Timers scheduled during execution will not run until explicitly advanced later.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n * await timerService.runOnlyPendingTimersAsync();\n * // Logs:\n * // first\n * ```\n *\n * @since 1.3.0\n */\n\n async runOnlyPendingTimersAsync(): Promise<void> {\n await Promise.resolve();\n this.runOnlyPendingTimers();\n }\n\n /**\n * Executes all timers whose scheduled time is less than or equal to the\n * current simulated time (`this.now`).\n *\n * @remarks\n * This internal method is called by {@link advanceTimersByTime},\n * {@link runAllTimers}, and {@link runOnlyPendingTimers} to trigger\n * due timers.\n * If `limitTimers` are provided, only timers included in that set are executed.\n * Repeating timers (`setInterval`) are rescheduled automatically until\n * their next execution time exceeds the current simulated time.\n *\n * @param limitTimers - Optional set of timer IDs to restrict execution.\n *\n * @internal\n * @since 1.1.0\n */\n\n private runDueTimers(limitTimers?: Set<number>): void {\n let executed = true;\n while (executed) {\n executed = false;\n\n const timers = Array.from(this.timers.values()).sort((a, b) => a.time - b.time);\n\n for (const timer of timers) {\n if (!this.timers.has(timer.id)) continue;\n if (limitTimers && !limitTimers.has(timer.id)) continue;\n\n if (timer.time <= this.now) {\n if (timer.interval !== null) {\n while (timer.time <= this.now) {\n timer.callback();\n timer.time += timer.interval;\n }\n } else {\n timer.callback();\n this.timers.delete(timer.id);\n }\n executed = true;\n }\n }\n }\n }\n}\n\n/**\n * Globally enables fake timers using the shared {@link TimerService}.\n *\n * @remarks\n * After calling this function, all calls to `setTimeout`, `setInterval`,\n * `clearTimeout`, and `clearInterval` will be intercepted by the\n * {@link TimerService} and stored in-memory instead of executing in real time.\n * This allows deterministic testing by manually advancing time with\n * {@link advanceTimersByTime}, {@link runAllTimers}, or\n * {@link runOnlyPendingTimers}.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 1000);\n * advanceTimersByTime(1000); // logs \"done\" immediately\n * ```\n *\n * @since 1.1.0\n */\n\nexport function useFakeTimers(): void {\n inject(TimerService).useFakeTimers();\n}\n\n/**\n * Restores real timers globally using the shared {@link TimerService}.\n *\n * @remarks\n * This function undoes the effects of {@link useFakeTimers}, restoring the\n * native implementations of `setTimeout`, `setInterval`, `clearTimeout`,\n * `clearInterval`, and `Date.now`.\n * After calling this, timers once again behave according to real system time,\n * and manual advancement methods like {@link advanceTimersByTime} no longer apply.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * // ...run tests with controlled time...\n * useRealTimers(); // restore native timers\n * ```\n *\n * @since 1.1.0\n */\n\nexport function useRealTimers(): void {\n inject(TimerService).useRealTimers();\n}\n\n/**\n * Executes all timers currently registered in the {@link TimerService}.\n *\n * @remarks\n * This function repeatedly runs all pending `setTimeout` and `setInterval`\n * callbacks until no timers remain.\n * It is equivalent to calling {@link TimerService.runAllTimers} on the\n * injected service instance and is useful for immediately flushing\n * all scheduled timers in tests.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n * runAllTimers(); // logs \"A\" then \"B\"\n * ```\n *\n * @since 1.1.0\n */\n\nexport function runAllTimers(): void {\n inject(TimerService).runAllTimers();\n}\n\n/**\n * Removes all scheduled fake timers from the {@link TimerService}.\n *\n * @remarks\n * This function clears all active timers registered in the shared timer service,\n * effectively canceling any pending callbacks that would have run during\n * timer advancement.\n *\n * It's useful for resetting the fake timer state between test cases to ensure\n * no lingering timers affect further tests or for scenarios where you\n * need to abort all pending operations.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n *\n * clearAllTimers(); // removes all scheduled timers\n * advanceTimersByTime(1000); // nothing happens, not show any logs\n * ```\n *\n * @since 1.3.0\n */\n\nexport function clearAllTimers(): void {\n inject(TimerService).clearAllTimers();\n}\n\n/**\n * Executes only the timers that are pending at the time of invocation.\n *\n * @remarks\n * This function runs the callbacks of timers that exist when the function\n * is called, without executing any new timers that may be scheduled\n * during their execution.\n * It delegates to {@link TimerService.runOnlyPendingTimers} on the injected\n * service instance.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n *\n * runOnlyPendingTimers();\n * // Logs only \"first\"; \"second\" is not executed yet\n * ```\n *\n * @since 1.1.0\n */\n\nexport function runOnlyPendingTimers(): void {\n inject(TimerService).runOnlyPendingTimers();\n}\n\n/**\n * Advances the simulated time by a specified number of milliseconds and\n * executes all timers that are due.\n *\n * @remarks\n * This function delegates to {@link TimerService.advanceTimersByTime}\n * on the injected service instance.\n * It is intended to be used after {@link useFakeTimers} to fast-forward\n * time in tests without waiting for real timers.\n *\n * @param ms - The number of milliseconds to advance (default is `0`).\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 500);\n * advanceTimersByTime(500); // logs \"done\"\n * ```\n *\n * @since 1.1.0\n */\n\nexport function advanceTimersByTime(ms: number = 0): void {\n inject(TimerService).advanceTimersByTime(ms);\n}\n\n/**\n * Asynchronous equivalent of {@link runAllTimers}.\n *\n * @remarks\n * Yields to the event loop before running all pending fake timers.\n * Useful when working with both Promises and fake timers.\n *\n * @example\n * ```ts\n * xJet.useFakeTimers();\n * Promise.resolve().then(() => console.log('promise done'));\n * setTimeout(() => console.log('timeout done'), 0);\n * await xJet.runAllTimersAsync();\n * // Logs:\n * // promise done\n * // timeout done\n * ```\n *\n * @since 1.3.0\n */\n\nexport async function runAllTimersAsync(): Promise<void> {\n await inject(TimerService).runAllTimersAsync();\n}\n\n/**\n * Asynchronous equivalent of {@link runOnlyPendingTimers}.\n *\n * @remarks\n * Yields to the event loop before running only timers that are currently pending.\n * Any timers scheduled by those callbacks will not be executed until a later call.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n * await runOnlyPendingTimersAsync();\n * // Logs only \"first\"\n * ```\n *\n * @since 1.3.0\n */\n\nexport async function runOnlyPendingTimersAsync(): Promise<void> {\n await inject(TimerService).runOnlyPendingTimersAsync();\n}\n", "/**\n * A regular expression pattern used to match variable-like strings prefixed with a `$` symbol.\n *\n * @default /\\$([#\\\\w.])+/g\n *\n * @see resolveVariable\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nconst VARIABLE_PATTERN = /\\$([#\\w.])+/g;\n\n/**\n * Formats a given value into a human-readable string representation.\n *\n * @param value - The value to be formatted\n * @returns The formatted string representation of the input value\n *\n * @remarks\n * This method ensures that non-string values are converted into a JSON string with\n * indentation for easier readability. If the input is a string, it is returned as-is.\n *\n * @example\n * ```ts\n * // String input is returned unchanged\n * const str = prettyFormat(\"hello\"); // Returns: \"hello\"\n *\n * // Objects are converted to indented JSON\n * const obj = prettyFormat({ name: \"John\", age: 30 });\n * // Returns:\n * // {\n * // \"name\": \"John\",\n * // \"age\": 30\n * // }\n * ```\n *\n * @see printf\n *\n * @since 1.0.0\n */\n\nexport function prettyFormat(value: unknown): string {\n if (typeof value === 'string') return value;\n\n return JSON.stringify(value, null, 4);\n}\n\n/**\n * Retrieves a value from a nested object structure based on a specified path.\n *\n * @param data - The object containing the nested data to traverse\n * @param path - An array of strings representing the sequence of keys to access the desired value\n * @returns The value found at the specified path within the object, or `undefined` if the path does not exist\n *\n * @remarks\n * This function safely traverses the given object structure without throwing errors\n * for missing keys or null/undefined values.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * profile: {\n * name: \"John Doe\",\n * email: \"john@example.com\"\n * }\n * }\n * };\n *\n * const name = getValueByPath(data, [\"user\", \"profile\", \"name\"]);\n * // Returns: \"John Doe\"\n *\n * const missing = getValueByPath(data, [\"user\", \"settings\", \"theme\"]);\n * // Returns: undefined\n * ```\n *\n * @see resolveVariable\n *\n * @since 1.0.0\n */\n\nexport function getValueByPath(data: Record<string, unknown>, path: string[]): unknown {\n if (!path.length || !data) return undefined;\n\n try {\n return path.reduce((obj, key) => {\n if (obj === null || obj === undefined || typeof obj !== 'object') {\n throw new Error('Path traversal failed');\n }\n\n return (obj as Record<string, unknown>)[key];\n }, data as unknown);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolves a variable token into its corresponding value from the provided data object.\n *\n * @param token - The variable token to resolve\n * @param data - The object containing data used for resolving the variable token\n * @param arrayIndex - The index value to be used if the token represents an array index (`$#`)\n * @returns The resolved value as a string, or the original token if resolution fails\n *\n * @remarks\n * This function assumes the use of dot notation in token paths to access nested properties\n * within the `data` object. Tokens starting with `$#` will be replaced by the array index.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * name: \"John\"\n * }\n * };\n *\n * const value1 = resolveVariable(\"$user.name\", data, 0);\n * // Returns: \"John\"\n *\n * const value2 = resolveVariable(\"$#\", data, 5);\n * // Returns: \"5\"\n * ```\n *\n * @see getValueByPath\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nexport function resolveVariable(token: string, data: Record<string, unknown>, arrayIndex: number): string {\n if (!token || typeof <unknown> token !== 'string' || !token.startsWith('$'))\n return token;\n\n if (token === '$#')\n return String(arrayIndex);\n\n const propertyPath = token.slice(1).split('.');\n const resolvedValue = getValueByPath(data, propertyPath);\n\n if (resolvedValue === undefined || resolvedValue === null) {\n return token;\n }\n\n if (typeof resolvedValue === 'object') {\n try {\n return JSON.stringify(resolvedValue, (key, value) => {\n if (key && typeof value === 'object')\n return '[Object]';\n\n return value;\n });\n } catch {\n return String(resolvedValue);\n }\n }\n\n return String(resolvedValue);\n}\n\n/**\n * Replaces variable placeholders within a template string with corresponding values from a provided data object.\n *\n * @param template - The template string containing variable placeholders\n * @param data - An object mapping variable names to their respective values\n * @param arrayIndex - The index to be applied when resolving variables that reference array values\n * @returns The resulting string with all variable placeholders replaced by their resolved values\n *\n * @throws Error - If a required variable cannot be resolved\n *\n * @remarks\n * The function uses a regular expression to identify variable placeholders within the template string\n * and replaces them with corresponding values derived from the `data` object.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * name: \"Jane\",\n * id: 42\n * },\n * status: \"active\"\n * };\n *\n * const result = interpolateVariables(\"User $user.name ($user.id) is $status\", data, 0);\n * // Returns: \"User Jane (42) is active\"\n * ```\n *\n * @see VARIABLE_PATTERN\n * @see resolveVariable\n *\n * @since 1.0.0\n */\n\nexport function interpolateVariables(template: string, data: Record<string, unknown>, arrayIndex: number): string {\n return template.replace(\n VARIABLE_PATTERN, (variableToken) => resolveVariable(variableToken, data, arrayIndex)\n );\n}\n\n/**\n * Formats a given string by interpolating it with the provided parameters.\n *\n * @param description - The format string containing variables or tokens to be replaced\n * @param params - An array of values to interpolate or substitute into the format string\n * @param index - An index used for specific token replacements (e.g., `%#`)\n * @returns The formatted string after performing substitutions and formatting\n *\n * @remarks\n * This function supports two formatting approaches:\n * 1. `$variable` style interpolation using the first object in the `params` array\n * 2. Printf-style format specifiers with the following options:\n * - `%p`: Pretty prints a value\n * - `%s`: Converts value to a string\n * - `%d`: Converts value to a numeric string\n * - `%i`: Converts value to an integer string (floor of the number)\n * - `%f`: Converts value to a floating-point string\n * - `%j`: Converts value to its JSON representation\n * - `%o`: Outputs the object's `toString` representation\n * - `%#`: Replaced with the provided `index`\n * - `%%`: Escapes the `%` character\n *\n * If the `description` contains `$`-style variables, it will interpolate those using the first object in the `params` array.\n * This behavior does not apply if the string also contains `%%`.\n *\n * @example\n * ```ts\n * // Format with printf-style specifiers\n * const result1 = printf(\"Value: %s, Number: %d\", [\"test\", 42], 0);\n * // Returns: \"Value: test, Number: 42\"\n *\n * // Format with variable interpolation\n * const data = { name: \"Alice\", age: 30 };\n * const result2 = printf(\"Name: $name, Age: $age\", [data], 0);\n * // Returns: \"Name: Alice, Age: 30\"\n * ```\n *\n * @see prettyFormat\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nexport function printf(description: string, params: Array<unknown>, index: number): string {\n let paramIndex = 0;\n // Handle $variable style interpolation first\n if (description.includes('$') && !description.includes('%%')) {\n description = interpolateVariables(description, <Record<string, unknown>> params[0], index);\n }\n\n return description.replace(/%([psdifjo#%])/g, (match, format) => {\n if (format === '%') return '%';\n if (format === '#') return String(index);\n\n const value = params[paramIndex++];\n switch (format) {\n case 'p':\n return prettyFormat(value);\n case 's':\n return String(value);\n case 'd':\n return Number(value).toString();\n case 'i':\n return Math.floor(Number(value)).toString();\n case 'f':\n return Number(value).toString();\n case 'j':\n return JSON.stringify(value);\n case 'o':\n return Object.prototype.toString.call(value);\n default:\n return match;\n }\n });\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { InvokeType } from '@shared/directives/interfaces/each-directive.interface';\n\n/**\n * Imports\n */\n\nimport { printf } from '@shared/components/printf.component';\n\n/**\n * Converts a template string and input data into an array of structured objects\n *\n * @param templateString - Template string containing column headings separated by pipe characters\n * @param inputData - Array of values to be organized according to the template structure\n * @returns Array of objects where each object represents a row with properties named after the headings\n *\n * @throws Error - When template headings are empty or missing pipe delimiters\n * @throws Error - When the input data length is not a multiple of the headings length\n *\n * @example\n * ```ts\n * const template = parseTemplate(`name|age|role`, ['John', 30, 'Developer', 'Jane', 25, 'Designer']);\n * // Returns: [\n * // { name: 'John', age: 30, role: 'Developer' },\n * // { name: 'Jane', age: 25, role: 'Designer' }\n * // ]\n * ```\n *\n * @see each - Function that uses parseTemplate for test case generation\n *\n * @since 1.0.0\n */\n\nexport function parseTemplate(templateString: TemplateStringsArray, inputData: Array<unknown>): Array<Record<string, unknown>> {\n // Extract the column headings and remove any leading/trailing whitespace\n const headings: string[] = templateString[0].split('|').map((h: string) => h.trim());\n if (headings.length === 0 || headings.some((h) => h === ''))\n throw new Error('Template string headings must not be empty and should contain pipe delimiters.');\n\n if ((inputData.length % headings.length) !== 0)\n throw new Error('Not enough arguments supplied for given headings.');\n\n return Array.from({ length: inputData.length / headings.length }, (_, rowIndex) => {\n return headings.reduce((acc, heading, columnIndex) => {\n acc[heading] = inputData[rowIndex * headings.length + columnIndex];\n\n return acc;\n }, {} as Record<string, unknown>);\n });\n}\n\n/**\n * Executes a function block as a test case with the specified description\n *\n * @template T - Type extending Array of unknown values\n * @param executor - The function that will execute each test case\n * @param args - Arguments representing test cases or a tagged template literal\n * @returns A function that accepts a test name, test block function, and optional timeout\n *\n * @throws Error - When called with fewer than 2 arguments\n *\n * @remarks\n * This method provides a way to directly invoke a test function with optional arguments.\n * It is typically used with the `each` function to create parameterized test cases.\n * The provided description will be used for test reporting and identification.\n *\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * // As part of the each function with direct arguments\n * test.each(1, 2, 3)('test with %s', (val) => {\n * expect(val).toBeGreaterThan(0);\n * });\n *\n * test.each(\n * { name: 'John', age: 30 },\n * { name: 'Jane', age: 25 }\n * )('User %s is %s years old', (name, age) => {\n * expect(typeof name).toBe('string');\n * expect(typeof age).toBe('number');\n * });\n *\n * test.each`\n * a | b | sum\n * ${ 1 } | ${ 2 } | ${ 3 }\n * ${ 2 } | ${ 5 } | ${ 7 }\n * `('adds $a + $b -> $sum', ({ a, b, sum }) => {\n * expect(a + b).toBe(sum);\n * });\n *\n * describe.each` a | b | expected ${ 1 } | ${ 2 } | ${ 3 } ${ 2 } | ${ 3 } | ${ 5 }`\n * ('%# adds $a and $b to get $expected', ({ a, b, expected }) => {\n * test('calculates sum', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see InvokeType - Type definition for the executor function\n * @see FunctionType - Type definition for the test block function\n * @see parseTemplate - Function used to parse tagged template literals\n *\n * @since 1.0.0\n */\n\nexport function each<T extends Array<unknown>>(executor: InvokeType, ...args: T) {\n if (args.length < 2) {\n throw new Error('`.each` must be called with at leas 2 argument or Tagged Template Literal.');\n }\n\n // eslint-disable-next-line\n const isTemplateStrings = args[0] instanceof Array && (<any> args[0]).raw !== undefined;\n const cases: Array<unknown> = isTemplateStrings ? parseTemplate(<TemplateStringsArray> args.shift(), args) : args;\n\n return (name: string, blockFn: FunctionType, timeout?: number): void => {\n cases.forEach((testCase, index) => {\n const parseArgs = Array.isArray(testCase) ? testCase : [ testCase ];\n executor(printf(name, parseArgs, Number(index)), blockFn, parseArgs, timeout);\n });\n };\n}\n", "export class TimeoutError extends Error {\n constructor(timeout: number, at: string, stack: string = '') {\n super(`Exceeded timeout of ${ timeout } ms at ${ at }`);\n\n // Ensure a correct prototype chain (important for `instanceof`)\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'xJetTimeoutError';\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = 'xJetFailingError';\n if(stack) {\n this.stack = `${ this.name }: ${ this.message }\\n${ stack }`;\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionLikeType } from '@remotex-labs/xjet-expect';\n\n/**\n * Imports\n */\n\nimport { TimeoutError } from '@errors/timeout.error';\nimport { inject } from '@symlinks/services/inject.service';\nimport { TimerService } from '@shared/services/timer.service';\n\n\n/**\n * Executes a given asynchronous or synchronous task with an optional timeout constraint.\n *\n * @typeParam T - The resolved value type.\n *\n * @param task - Either a function that returns a value or promise, or a promise itself.\n * @param delay - Timeout in milliseconds, or `-1` to disable the timeout.\n * @param at - A contextual label (e.g., method name or operation name) to aid debugging.\n * @param stack - Optional stack trace to provide more detailed error context.\n *\n * @throws {@link TimeoutError} If the task does not complete within the specified `delay`\n * (only when `delay` is not `-1`).\n *\n * @remarks\n * The function accepts either:\n * - a function returning a value or a promise, or\n * - a promise directly.\n *\n * If `delay` is `-1`, no timeout is applied. Otherwise the task is raced against\n * a timer and a {@link TimeoutError} is thrown on expiry.\n *\n * @example\n * ```ts\n * // Passing a function\n * await withTimeout(\n * () => fetchData(),\n * 5000,\n * 'fetchData'\n * );\n *\n * // Passing a promise directly\n * await withTimeout(\n * fetchData(),\n * 5000,\n * 'fetchDataDirect'\n * );\n *\n * // No timeout\n * await withTimeout(fetchData(), -1, 'fetchDataNoTimeout');\n * ```\n *\n * @since 1.1.0\n */\n\nexport async function withTimeout<T>(\n task: FunctionLikeType<T | Promise<T>> | Promise<T> | T, delay: number, at: string, stack?: string\n): Promise<T> {\n const timers = inject(TimerService);\n\n const taskPromise =\n typeof task === 'function'\n ? Promise.resolve((task as FunctionLikeType<T | Promise<T>>)())\n : Promise.resolve(task);\n\n if (delay === -1 || !timers.originalSetTimeout) {\n return taskPromise;\n }\n\n let timeoutId: ReturnType<typeof setTimeout>;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = timers.originalSetTimeout?.(\n () => reject(new TimeoutError(delay, at, stack)),\n delay\n );\n });\n\n try {\n return await Promise.race([ taskPromise, timeoutPromise ]);\n } finally {\n timers.originalClearTimeout?.(timeoutId!);\n }\n}\n\n", "/**\n * Imports\n */\n\nimport { ExecutionError } from '@shared/errors/execution.error';\n\n\nexport class FailingError extends ExecutionError {\n\n\n constructor(stack: string) {\n super('Failing test passed even though it was supposed to fail. Remove `.failing` to remove error.');\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FailingError);\n }\n\n this.name = 'xJetFailingError';\n this.stack = `${ this.name }: ${ this.message }\\n${ stack }`;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestFlagsType } from '@shared/models/interfaces/test-model.interface';\nimport type { ContextInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { withTimeout } from '@components/timeout.component';\nimport { FailingError } from '@shared/errors/failing.error';\nimport { MessageType } from '@messages/constants/report.constant';\nimport { emitEvent, emitStatus } from '@shared/services/emit.service';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\nimport { TestExecutionType } from '@shared/models/constants/test-model.constants';\nimport { type ContextType, type FunctionLikeType, type FunctionType, isPromise } from '@remotex-labs/xjet-expect';\n\n/**\n * Represents a test case within the testing framework that manages execution,\n * timing, and reporting of individual tests.\n *\n * @example\n * ```ts\n * const test = new TestModel(\n * 'should validate user input correctly',\n * async () => {\n * const result = await validateInput('test@example.com');\n * expect(result.isValid).toBe(true);\n * },\n * 2000\n * );\n *\n * // Set ancestry to show the test's location in the test hierarchy\n * test.ancestry = ['Authentication', 'Input Validation'];\n *\n * // Execute the test\n * await test.execute();\n * ```\n *\n * @remarks\n * The TestModel is responsible for tracking test execution time, handling timeouts,\n * managing test context, and reporting test status through the emit service.\n * It supports both synchronous and promise-based test implementations.\n *\n * @throws FailingError - When a test fails due to assertions or errors\n *\n * @see ContextInterface\n * @see EmitActionEventType\n * @see EmitStatusEventType\n * @see InvocationLocationType\n *\n * @since 1.0.0\n */\n\nexport class TestModel {\n /**\n * Stores the hierarchical path of parent test descriptions that contain this test\n *\n * @default []\n * @since 1.0.0\n */\n\n readonly ancestry: Array<string> = [];\n\n /**\n * Stores information about where this test is being executed in the source code\n *\n * @see InvocationLocationType\n * @since 1.0.0\n */\n\n private executionLocation: string = '';\n\n /**\n * Timestamp when test execution started, measured in milliseconds\n *\n * @default 0\n * @since 1.0.0\n */\n\n private executionStartTime: number = 0;\n\n /**\n * Creates a new instance of the TestModel to represent an executable test.\n *\n * @param description - The test description that explains the purpose of the test\n * @param testImplementation - The function containing the actual test code to be executed\n * @param timeoutDuration - The maximum time in milliseconds that the test is allowed to run\n * @param testParameters - An array of parameters to be passed to the test implementation\n * @param testOptions - Configuration options that control test execution behavior\n *\n * @example\n * ```ts\n * const test = new TestModel(\n * 'should calculate the correct sum',\n * () => expect(sum(2, 2)).toBe(4),\n * 5000\n * );\n * ```\n *\n * @since 1.0.0\n */\n\n constructor(\n readonly description: string,\n private readonly testImplementation: FunctionType,\n private readonly timeoutDuration: number,\n private readonly testParameters: unknown[] = [],\n private readonly testOptions: TestFlagsType = {}\n ) {}\n\n /**\n * Provides access to the test configuration options.\n *\n * @returns The test configuration options that control test execution behavior\n *\n * @since 1.0.0\n */\n\n get options(): TestFlagsType {\n return this.testOptions;\n }\n\n /**\n * Sets the location where the test is being executed.\n *\n * @param location - The execution location information containing position details\n *\n * @see InvocationLocationType\n * @since 1.0.0\n */\n\n setExecutionLocation(location: string): void {\n this.executionLocation = location;\n }\n\n /**\n * Applies execution control options to the test, allowing it to be skipped or run exclusively.\n *\n * @param skip - Flag indicating whether the test should be skipped during execution\n * @param only - Flag indicating whether only this test should be executed\n *\n * @remarks\n * This method uses logical OR assignment (||=) to ensure options are only set to true and\n * never reset from true to false. Existing flag values take precedence.\n *\n * @example\n * ```ts\n * testInstance.applyExecutionFlags(true, false); // Will mark test to be skipped\n * testInstance.applyExecutionFlags(false, true); // Will mark test to run exclusively\n * ```\n *\n * @see TestFlagsType\n * @since 1.0.0\n */\n\n applyExecutionFlags(skip?: boolean, only?: boolean): void {\n this.testOptions.skip ||= skip;\n this.testOptions.only ||= only;\n }\n\n /**\n * Sets the ancestry for this test by adding parent test descriptions to the ancestry chain.\n *\n * @param parentTests - Array of parent test description strings representing the test hierarchy\n *\n * @example\n * ```ts\n * const childTest = new TestModel(\"should work\", () => {}, 5000);\n * childTest.setAncestry([\"describe block A\", \"describe block B\"]);\n * ```\n *\n * @since 1.0.0\n */\n\n setAncestry(parentTests: string[]): void {\n this.ancestry.push(...parentTests);\n }\n\n /**\n * Executes the test within the specified context, managing test lifecycle and status reporting.\n *\n * @param context - The test execution context containing shared state and utilities\n * @param runLifecycleHooks - Function that runs before/after hooks at appropriate times\n * @param isExclusiveMode - Flag indicating if tests are running in exclusive mode (only marked tests)\n * @returns Promise that resolves when the test execution completes\n *\n * @throws Error - If any unhandled exceptions occur during test execution that aren't captured\n *\n * @remarks\n * The method tracks execution time, manages test lifecycle, handles skipping logic, and processes\n * test results. It also notifies about test status changes through observer pattern implementation.\n *\n * @example\n * ```ts\n * // Running a test with context and lifecycle hooks\n * await testInstance.run(\n * testContext,\n * async (hookType, ctx) => {\n * await runHooks(hookType, ctx);\n * },\n * false\n * );\n * ```\n *\n * @see HookType\n * @see ActionType\n * @see ContextInterface\n *\n * @since 1.0.0\n */\n\n async run(\n context: ContextType<ContextInterface>,\n runLifecycleHooks: FunctionLikeType<Promise<void>, [ HookType, ContextType<ContextInterface> ]>,\n isExclusiveMode: boolean = false\n ): Promise<void> {\n inject(SuiteState).test = this;\n this.executionStartTime = Date.now();\n\n if (this.shouldSkipDueToSetupErrors(context))\n return;\n\n if (this.determineSkipAction(isExclusiveMode)) return;\n\n try {\n await this.executeTestWithLifecycle(context, runLifecycleHooks);\n this.validateTestOutcome();\n } catch (error) {\n this.notifyTestFailure(error);\n if(globalThis.__XJET?.runtime.bail) {\n context.hasError = true;\n }\n } finally {\n inject(SuiteState).test = undefined;\n }\n }\n\n /**\n * Determines whether a test should be skipped due to errors in setup hooks.\n *\n * @param context - The test execution context containing shared state and potential setup errors\n * @returns Boolean indicating whether the test should be skipped\n *\n * @remarks\n * This method checks if any errors occurred in beforeAll hooks and reports them as test failures.\n * Tests are skipped when setup errors are present to prevent misleading test results.\n *\n * @see ContextInterface\n *\n * @internal\n *\n * @since 1.0.0\n */\n\n private shouldSkipDueToSetupErrors(context: ContextType<ContextInterface>): boolean {\n if (context.beforeAllErrors && context.beforeAllErrors.length > 0) {\n this.notifyTestFailure(context.beforeAllErrors as Array<unknown>);\n\n return true;\n }\n\n return false;\n }\n\n private determineSkipAction(isExclusiveMode: boolean): boolean {\n if(inject(SuiteState).isOnlyMode && !this.testOptions.only) {\n this.notifyTestStatus(true);\n\n return true;\n }\n\n if (this.testOptions.skip || this.testOptions.todo) {\n this.notifyTestStatus(this.testOptions.skip, this.testOptions.todo);\n\n return true;\n }\n\n if(isExclusiveMode && !this.testOptions.only) {\n this.notifyTestStatus(true);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Executes a test with proper lifecycle hooks and timeout management.\n *\n * @param context - The test execution context containing shared state and utilities\n * @param runLifecycleHooks - Function that runs the specified hook type with the given context\n *\n * @returns Promise that resolves when the test and all its lifecycle hooks have completed\n *\n * @throws TimeoutError - When the test execution exceeds the configured timeout duration\n *\n * @remarks\n * This method orchestrates the complete test execution flow including:\n * 1. Running beforeEach hooks\n * 2. Executing the actual test body with timeout protection\n * 3. Running afterEach hooks regardless of test outcome\n *\n * @internal\n * @see HookType\n * @see ContextInterface\n * @see withTimeout\n *\n * @since 1.0.0\n */\n\n private async executeTestWithLifecycle(\n context: ContextType<ContextInterface>,\n runLifecycleHooks: FunctionLikeType<Promise<void>, [ HookType, ContextType<ContextInterface> ]>\n ): Promise<void> {\n await runLifecycleHooks(HookType.BEFORE_EACH, context);\n\n await withTimeout<void>(\n this.executeTestWithContext(context),\n this.timeoutDuration,\n `'${ this.timeoutDuration }' test`,\n this.executionLocation\n );\n\n await runLifecycleHooks(HookType.AFTER_EACH, context);\n }\n\n /**\n * Validates the test outcome, handling failing tests and notifying of success.\n *\n * @throws FailingError - When a test is marked as failing but successfully completes\n *\n * @remarks\n * This method implements special handling for tests marked with the 'failing' option.\n * For failing tests, it throws an error if the test unexpectedly succeeds.\n * For normal tests, it reports a successful test outcome.\n *\n * @internal\n * @see ActionType\n * @see FailingError\n *\n * @since 1.0.0\n */\n\n private validateTestOutcome(): void {\n if (this.testOptions.failing) {\n throw new FailingError(this.executionLocation!);\n }\n\n this.notifyTestAction();\n }\n\n /**\n * Determines if the test is using callback-style asynchronous execution.\n *\n * @returns Boolean indicating whether the test uses the callback pattern\n *\n * @remarks\n * This method analyzes the test implementation's parameter count to detect callback-style tests.\n * It identifies two callback patterns:\n * 1. A test function that expects exactly one parameter (the callback) with no test parameters\n * 2. A test function that expects exactly two parameters (test arguments and callback)\n *\n * The callback pattern is an alternative to Promise-based async tests.\n *\n * @internal\n * @since 1.0.0\n */\n\n private isCallbackStyle(): boolean {\n if (this.testImplementation.length === 1 && this.testParameters.length === 0)\n return true;\n\n // Or if it expects more parameters (test args + callback)\n return this.testImplementation.length === 2;\n }\n\n private getExecutionStrategy(): TestExecutionType {\n if (isPromise(this.testImplementation)) return TestExecutionType.ASYNC;\n if (this.isCallbackStyle()) return TestExecutionType.CALLBACK;\n\n return TestExecutionType.SYNC;\n }\n\n /**\n * Executes the test function with the appropriate execution strategy based on its type.\n *\n * @param context - The test execution context containing shared state and utilities\n *\n * @returns Promise that resolves when the test execution completes\n *\n * @throws Error - When the test execution fails for any reason\n *\n * @remarks\n * This method determines and applies the correct execution strategy for the test:\n * - For synchronous and async tests, it calls the test implementation directly with the context\n * - For callback-style tests, it delegates to a specialized execution method\n * The method ensures proper 'this' binding by using Function.prototype.apply\n *\n * @internal\n * @see ContextInterface\n * @see TestExecutionType\n *\n * @since 1.0.0\n */\n\n private async executeTestWithContext(context: ContextType<ContextInterface>): Promise<void> {\n const strategy = this.getExecutionStrategy();\n\n switch (strategy) {\n case TestExecutionType.ASYNC:\n case TestExecutionType.SYNC:\n await this.testImplementation.apply(context, this.testParameters);\n break;\n case TestExecutionType.CALLBACK:\n await this.executeCallbackStyleTest(context);\n break;\n }\n }\n\n /**\n * Executes a callback-style test by wrapping it in a Promise.\n *\n * @param context - The test execution context containing shared state and utilities\n *\n * @returns Promise that resolves when the callback is invoked without an error, or rejects when called with an error\n *\n * @throws Error - When the callback is invoked with an error parameter\n *\n * @remarks\n * This method adapts callback-style test functions to work within a Promise-based execution flow.\n * It creates a Promise wrapper around the test function and:\n * 1. Defines a callback function that resolves/rejects the Promise based on error parameter\n * 2. Appends this callback to the original test parameters\n * 3. Invokes the test with proper context binding using Function.prototype.apply\n *\n * The callback function follows Node.js convention with an optional error as first parameter.\n *\n * @internal\n * @see ContextInterface\n *\n * @since 1.0.0\n */\n\n private async executeCallbackStyleTest(context: ContextType<ContextInterface>): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const callbackFn = (error?: string | { message: string }): void => {\n if (error) reject(error);\n resolve();\n };\n\n const allParameters = [ ...this.testParameters ];\n allParameters.push(callbackFn);\n\n this.testImplementation.apply(context, allParameters);\n });\n }\n\n /**\n * Calculates the elapsed execution time of the test in milliseconds.\n *\n * @returns Number representing the test execution duration in milliseconds\n *\n * @remarks\n * This method computes the time difference between now and when the test started execution.\n * It returns 0 if the test has not yet started (when executionStartTime is 0).\n * The time measurement uses the system clock via Date.now().\n *\n * @internal\n * @since 1.0.0\n */\n\n private getExecutionDuration(): number {\n if (this.executionStartTime === 0) return 0;\n\n return Date.now() - this.executionStartTime;\n }\n\n\n private notifyTestStatus(skip: boolean = false, todo: boolean = false): void {\n emitStatus(MessageType.Test, {\n todo: todo,\n skipped: skip,\n ancestry: this.ancestry,\n description: this.description\n });\n }\n\n /**\n * Emits an action event when a test execution has a significant state change.\n *\n * @param type - The type of action event to emit (e.g., start, complete, skip)\n * @param errors - Collection of errors that occurred during test execution\n *\n * @remarks\n * This method broadcasts notifications about test execution actions through the event system.\n * It includes comprehensive information about the test:\n * - Any errors that occurred\n * - Test type as a KindType\n * - The test's ancestry (parent hierarchy)\n * - Execution duration up to the point of notification\n * - Source code location information\n * - The test's description text\n * These action events are typically consumed by reporters and test runners.\n *\n * @internal\n * @see KindType\n * @see EmitActionEventType\n *\n * @since 1.0.0\n */\n\n private notifyTestAction(errors: Array<unknown> = []): void {\n emitEvent(MessageType.Test, {\n errors: <Array<Error>> errors,\n ancestry: this.ancestry,\n duration: this.getExecutionDuration(),\n description: this.description\n });\n }\n\n /**\n * Emits a test failure action event with the associated error information.\n *\n * @param error - The error or errors that caused the test to fail\n *\n * @remarks\n * This method standardizes the reporting of test failures by:\n * 1. Ensuring errors are always passed as an array\n * 2. Converting single errors to array format when needed\n * 3. Delegating to the more general notifyTestAction method with the FAILURE action type\n * It serves as a specialized wrapper around the general action notification system.\n *\n * @internal\n * @see ActionType\n *\n * @since 1.0.0\n */\n\n private notifyTestFailure(error: unknown): void {\n this.notifyTestAction(Array.isArray(error) ? error : [ error ]);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { TestFlagsType } from '@shared/models/interfaces/test-model.interface';\nimport type { TestCallbackType, TestDirectiveInterface } from '@shared/directives/interfaces/test-directive.interface';\n\n/**\n * Imports\n */\n\nimport { each } from './each.directive';\nimport { TestModel } from '@shared/models/test.model';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { getTrimmedStackString } from '@components/location.component';\n\n/**\n * Implementation of the test directive that allows for test definition with chainable modifiers.\n * Acts as a function that can be invoked directly while also providing chainable property access.\n *\n * @template T - Type parameter for the test callback return type\n *\n * @param description - The test description\n * @param block - The test implementation function\n * @param timeout - Optional timeout in milliseconds\n *\n * @returns void\n *\n * @throws Error - When attempting to nest tests inside other tests\n * @throws Error - When using incompatible flag combinations (e.g., skip with only)\n *\n * @remarks\n * This class extends Function to allow it to be invoked as a function while also\n * providing methods and properties. It uses a Proxy to capture function invocations\n * and redirects them to the invoke method.\n *\n * @example\n * ```ts\n * // Basic test\n * test('should work', () => {\n * expect(2 + 2).toBe(4);\n * });\n *\n * // With modifiers\n * test.only('runs exclusively', () => {\n * expect(true).toBe(true);\n * });\n *\n * // Parameterized tests\n * test.each([1, 2, 3])('test with value %s', (value) => {\n * expect(typeof value).toBe('number');\n * });\n * ```\n *\n * @see SuiteState\n * @see TestDirectiveInterface\n *\n * @since 1.0.0\n */\n\nexport class TestDirective extends Function {\n /**\n * Singleton instance of the TestDirective class.\n *\n * @see TestDirectiveInterface\n * @since 1.0.0\n */\n\n private static instance?: TestDirective;\n\n /**\n * Error messages for invalid flag combinations in test configuration.\n *\n * @since 1.0.0\n */\n\n private static readonly ERROR_MESSAGES = {\n SKIP_ONLY: 'Cannot use \"only\" flag on skipped test',\n ONLY_SKIP: 'Cannot use \"skip\" flag on only test',\n SKIP_TODO: 'Cannot use \"todo\" flag on skipped test',\n SKIP_FAILING: 'Cannot use \"failing\" flag on skipped test'\n };\n\n /**\n * Default timeout in milliseconds for test execution\n * @since 1.0.0\n */\n\n private static readonly DEFAULT_TIMEOUT = globalThis.__XJET?.runtime.timeout ?? 5000;\n\n /**\n * Configuration options controlling test behavior\n\n * @see TestFlagsType\n * @since 1.0.0\n */\n\n private options: TestFlagsType = {};\n\n /**\n * @param invokationStack - The precise source code invocationStack where the error occurred\n */\n\n private invocationStack: string = '';\n\n /**\n * Private constructor that initializes the TestDirective instance and returns a proxied version.\n *\n * @returns A Proxy that handles direct function invocation by redirecting to the invoke method\n *\n * @remarks\n * The constructor is private to enforce the singleton pattern. It creates a Proxy\n * that allows the object to be called as a function while maintaining its object properties.\n * When called as a function, the proxy redirects the call to the invoke method.\n *\n * @internal\n * @see invoke\n *\n * @since 1.0.0\n */\n\n private constructor() {\n super();\n\n return new Proxy(this, {\n apply: (target, _, args: [string, FunctionType, number?]): void => {\n const [ description, block, timeout ] = args;\n this.invocationStack = getTrimmedStackString(2);\n\n target.invoke(description, block, [], timeout);\n }\n });\n }\n\n /**\n * Returns the singleton instance of TestDirective, creating it if it doesn't exist\n *\n * @returns The singleton instance of the test directive implementation\n *\n * @remarks\n * This method implements the singleton pattern, ensuring only one instance of the test directive exists\n * throughout the application lifecycle\n *\n * @example\n * ```ts\n * const test = TestDirective.getInstance();\n * test('my test', () => {\n * // test implementation\n * });\n * ```\n *\n * @see TestDirectiveInterface\n *\n * @since 1.0.0\n */\n\n static getInstance(): TestDirectiveInterface {\n if (!TestDirective.instance) {\n TestDirective.instance = new TestDirective();\n }\n\n return TestDirective.instance as unknown as TestDirectiveInterface;\n }\n\n /**\n * Returns the singleton instance of TestDirective, creating it if it doesn't exist.\n *\n * @returns The singleton instance of TestDirective cast to TestDirectiveInterface\n *\n * @remarks\n * This method implements the Singleton pattern to ensure only one instance of\n * TestDirective exists in the application. It creates the instance on the first call\n * and returns the existing instance on subsequent calls.\n *\n * @example\n * ```ts\n * const test = TestDirective.getInstance();\n * test('example test', () => {\n * expect(true).toBe(true);\n * });\n * ```\n *\n * @since 1.0.0\n */\n\n get skip(): this {\n if (this.options.only) throw new Error(TestDirective.ERROR_MESSAGES.ONLY_SKIP);\n this.options.skip = true;\n\n return this;\n }\n\n /**\n * Sets the 'only' flag for this test, making it the only test to run in its suite.\n *\n * @returns This instance with the 'only' flag set\n *\n * @throws Error - When attempting to set 'only' flag on a skipped test\n *\n * @example\n * ```ts\n * test.only('this is the only test that will run', () => {\n * expect(true).toBe(true);\n * });\n * ```\n *\n * @see skip\n * @since 1.0.0\n */\n\n get only(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_ONLY);\n this.options.only = true;\n\n return this;\n }\n\n /**\n * Marks a test as a todo item, indicating it's planned but not yet implemented\n *\n * @throws Error - When attempting to use todo flag on a skipped test\n *\n * @remarks\n * Todo tests appear in test reports to remind developers of planned work,\n * but don't execute any test code\n *\n * @example\n * ```ts\n * // Define a todo test\n * test.todo('feature that needs implementation');\n * ```\n *\n * @see TestFlagsType\n *\n * @since 1.0.0\n */\n\n get todo(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_TODO);\n this.options.todo = true;\n\n return this;\n }\n\n /**\n * Marks the test as expected to fail.\n *\n * @returns This instance with the 'failing' flag set\n *\n * @throws Error - When attempting to mark a skipped test as failing\n *\n * @example\n * ```ts\n * test.failing('this test is expected to fail', () => {\n * throw new Error('This is an expected failure');\n * });\n * ```\n *\n * @see skip\n * @since 1.0.0\n */\n\n get failing(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_FAILING);\n this.options.failing = true;\n\n return this;\n }\n\n /**\n * Creates a parameterized test using template strings.\n *\n * @template T - Array type containing the values to be used in the test\n *\n * @param string - Template string array used to create the test title\n * @param placeholders - Values to be inserted into the template string\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each`\n * a | b | expected\n * ${1} | ${1} | ${2}\n * ${2} | ${2} | ${4}\n * `('returns $expected when $a is added to $b', ({a, b, expected}) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each.array\n * @since 1.0.0\n */\n\n each<T extends ReadonlyArray<unknown>>(string: TemplateStringsArray, ...placeholders: T): TestCallbackType<Record<string, T[number]>>;\n\n /**\n * Creates a parameterized test using arrays of test cases.\n *\n * @template T - Type representing the test case data structure\n *\n * @param cases - Arrays containing test case values\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T extends Array<unknown> | [unknown]>(...cases: T[]): TestCallbackType<T>; // array\n\n /**\n * Creates a parameterized test using individual test case objects or primitive values.\n *\n * @template T - Type representing the test case data\n *\n * @param args - Test case objects or primitive values\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * { a: 1, b: 1, expected: 2 },\n * { a: 1, b: 2, expected: 3 },\n * { a: 2, b: 2, expected: 4 }\n * )('adds $a + $b to equal $expected', ({ a, b, expected }) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T>(...args: readonly T[]): TestCallbackType<T>; // object, and primitives\n\n /**\n * Creates a parameterized test using arrays of primitive values as test cases.\n *\n * @template T - Array type containing the primitive test values\n *\n * @param args - Arrays of primitive values to be used as test cases\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 2, 3],\n * [4, 5, 9],\n * [6, 7, 13]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T extends Array<unknown>>(...args: T): TestCallbackType<T[number]>; // primitives\n\n /**\n * Creates a parameterized test using various input formats.\n *\n * @param args - Test case data in array format\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * This method delegates to the implementation after binding the invoke method to the current context.\n *\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each.table\n * @see each.array\n * @since 1.0.0\n */\n\n each(...args: Array<unknown>): TestCallbackType<unknown> {\n return each(this.invoke.bind(this), ...args);\n }\n\n /**\n * Invokes a test with the provided description, test function, arguments, and optional timeout.\n *\n * @param description - The description of the test to be displayed in test reports\n * @param block - The test function containing the test logic\n * @param args - Additional arguments to be passed to the test function\n * @param timeout - Optional timeout value in milliseconds for the test\n *\n * @throws TestNestingError - When attempting to create a nested test\n *\n * @remarks\n * This method handles the complete test registration flow, including validation,\n * creation, registration, and flag management. If no test function is provided,\n * the test will be automatically marked as todo.\n *\n * @example\n * ```ts\n * invoke('should sum two numbers', (a, b) => {\n * expect(sum(a, b)).toBe(a + b);\n * }, [5, 10], 2000);\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n invoke(description: string, block: FunctionType, args: Array<unknown> = [], timeout?: number): void {\n this.validateTestNesting(description);\n\n // Auto-set todo flag if no test function provided\n if (!block) {\n this.options.todo = true;\n }\n\n // Create and register the test\n const test = this.createTest(description, block, args, timeout);\n this.registerTest(test, this.invocationStack);\n\n // Reset options after test creation\n this.resetFlags();\n }\n\n /**\n * Validates that tests are not being nested inside other tests.\n *\n * @param description - The description of the test being validated\n *\n * @throws Error - When a test is nested inside another test, with details about both tests\n *\n * @remarks\n * Nesting tests is not supported in the testing framework as it can lead to unpredictable behavior\n * and difficult-to-debug test scenarios.\n *\n * @internal\n * @since 1.0.0\n */\n\n private validateTestNesting(description: string): void {\n const runningTest = inject(SuiteState).test;\n if (runningTest) {\n // set invokation\n throw new Error(`Cannot nest a test inside a test '${ description }' in '${ runningTest.description }'`);\n }\n }\n\n /**\n * Creates a new TestModel with the current configuration\n */\n private createTest(description: string, block: FunctionType, args: Array<unknown>, timeout?: number): TestModel {\n return new TestModel(\n description,\n block,\n timeout ?? TestDirective.DEFAULT_TIMEOUT,\n args,\n { ...this.options } // Clone options to prevent shared references\n );\n }\n\n /**\n * Registers a test with the test suite and sets its execution invocationStack.\n *\n * @param test - The test model to register\n * @param location - The precise source code invocationStack where the error occurred\n *\n * @remarks\n * This method determines the invocationStack where the test was invoked in the source code\n * and attaches that information to the test before adding it to the suite state.\n * Location information is useful for error reporting and test navigation.\n *\n * @internal\n * @since 1.0.0\n */\n\n private registerTest(test: TestModel, location: string): void {\n if (location) {\n test.setExecutionLocation(location);\n }\n inject(SuiteState).addTest(test);\n }\n\n /**\n * Resets all test configuration options to their default state.\n *\n * @returns Nothing\n *\n * @remarks\n * This method clears all previously set options to ensure that configuration\n * from one test doesn't leak into subsequent tests.\n *\n * @internal\n * @since 1.0.0\n */\n\n private resetFlags(): void {\n this.options = {};\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeCallbackType } from '@shared/directives/interfaces/describe-directive.interface';\nimport type { DescribeDirectiveInterface } from '@shared/directives/interfaces/describe-directive.interface';\n\n/**\n * Imports\n */\n\nimport { SuiteState } from '@shared/states/suite.state';\nimport { each } from '@shared/directives/each.directive';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Implementation of the describe directive that allows for test suite definition with chainable modifiers.\n * Acts as a function that can be invoked directly while also providing chainable property access.\n *\n * @param description - The test suite description\n * @param block - The test suite implementation function\n *\n * @throws Error - When attempting to nest describe blocks inside tests\n * @throws Error - When using incompatible flag combinations (e.g., skip with only)\n *\n * @remarks\n * This class extends Function to allow it to be invoked as a function while also\n * providing methods and properties. It uses a Proxy to capture function invocations\n * and redirects them to the invoke method.\n *\n * The describe directive creates a group of related tests, providing organization and structure\n * to test suites. It supports chainable modifiers for customizing test suite behavior,\n * and parameterized testing via the 'each' method.\n *\n * @example\n * ```ts\n * // Basic describe block\n * describe('Calculator', () => {\n * test('should add numbers', () => {\n * expect(2 + 2).toBe(4);\n * });\n * });\n *\n * // With modifiers\n * describe.only('Priority feature', () => {\n * test('important test case', () => {\n * expect(true).toBe(true);\n * });\n * });\n *\n * // With parameterized tests using each\n * describe.each([1, 2, 3])('Math operations for %s', (value) => {\n * test('square', () => {\n * expect(value * value).toBeGreaterThan(0);\n * });\n * });\n * ```\n *\n * @see SuiteState\n * @see DescribeDirectiveInterface\n *\n * @since 1.0.0\n */\n\nexport class DescribeDirective extends Function {\n /**\n * Singleton instance of the DescribeDirective class.\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n private static instance: DescribeDirectiveInterface | null = null;\n\n /**\n * Configuration options controlling test suite behavior\n *\n * @see DescribeOptionsInterface\n * @since 1.0.0\n */\n\n private options: DescribeOptionsInterface = {};\n\n /**\n * Private constructor that initializes the DescribeDirective instance and returns a proxied version.\n *\n * @returns A Proxy that handles direct function invocation by redirecting to the invoke method\n *\n * @remarks\n * The constructor is private to enforce the singleton pattern. It creates a Proxy\n * that allows the object to be called as a function while maintaining its object properties.\n * When called as a function, the proxy redirects the call to the invoke method.\n *\n * @internal\n * @see invoke\n *\n * @since 1.0.0\n */\n\n private constructor() {\n super();\n\n return <this>new Proxy(this, {\n apply(target, thisArg, args: [ string, FunctionType ]): void {\n target.invoke(args[0], args[1]);\n }\n });\n }\n\n /**\n * Returns the singleton instance of DescribeDirective, creating it if it doesn't exist\n *\n * @returns The singleton instance of the describe directive implementation\n *\n * @remarks\n * This method implements the singleton pattern, ensuring only one instance of the describe directive\n * exists throughout the application lifecycle.\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n static getInstance(): DescribeDirectiveInterface {\n if (!DescribeDirective.instance) {\n DescribeDirective.instance = <DescribeDirectiveInterface><unknown>new DescribeDirective();\n }\n\n return DescribeDirective.instance;\n }\n\n /**\n * Creates a skipped test suite that will be recognized but not executed during test runs\n *\n * @returns The same DescribeDirective instance with skip flag enabled, allowing for method chaining\n * @throws Error - When attempting to combine with 'only' flag which would create conflicting behavior\n *\n * @remarks\n * When applied, the test suite will be marked as skipped in test reports but won't be executed.\n * Cannot be combined with the 'only' modifier due to conflicting behavior.\n *\n * @example\n * ```ts\n * describe.skip('temporarily disabled suite', () => {\n * test('will not run', () => {\n * expect(result).toBe(true);\n * });\n * });\n * ```\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n get skip(): this {\n if (this.options.only) throw new Error('Cannot use \"skip\" flag on only test');\n this.options.skip = true;\n\n return this;\n }\n\n /**\n * Creates an exclusive test suite that will run while other non-exclusive suites are skipped\n *\n * @returns The same DescribeDirective instance with only flag enabled, allowing for method chaining\n * @throws Error - When attempting to combine with 'skip' flag which would create conflicting behavior\n *\n * @remarks\n * When applied, only this test suite and other suites marked with 'only' will be executed.\n * This is useful for focusing on specific test suites during development or debugging.\n * Cannot be combined with the 'skip' modifier due to conflicting behavior.\n *\n * @example\n * ```ts\n * describe.only('focus on this suite', () => {\n * test('will run', () => {\n * expect(result).toBe(expectedValue);\n * });\n * });\n * ```\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n get only(): this {\n if (this.options.skip) throw new Error('Cannot use \"only\" flag on skipped test');\n this.options.only = true;\n\n return this;\n }\n\n /**\n * Generates parameterized test suites from template strings and placeholders.\n *\n * @template T - An array type extending ReadonlyArray<unknown> that contains the placeholder values\n *\n * @param string - A template string array that defines the structure of test suite descriptions\n * @param placeholders - Values to be inserted into the template strings to create test suites\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the number of placeholders doesn't match the template string requirements\n *\n * @remarks\n * This method uses tagged template literals to create parameterized test suites.\n * The values provided as placeholders will be passed to describe callbacks as named parameters.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the parameters in each row as function arguments.\n * - timeout (optional): Number - Time in milliseconds to wait for each row before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each`\n * a | b | expected\n * ${1} | ${1} | ${2}\n * ${1} | ${2} | ${3}\n * ${2} | ${2} | ${4}\n * `('addition: $a + $b = $expected', ({a, b, expected}) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends ReadonlyArray<unknown>>(string: TemplateStringsArray, ...placeholders: T): DescribeCallbackType<Record<string, T[number]>>;\n\n /**\n * Creates parameterized test suites from arrays of test case values.\n *\n * @template T - A type extending Array<unknown> or [unknown] that contains the test case values\n *\n * @param cases - Arrays of values representing individual test cases\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the test cases have inconsistent formats or types\n *\n * @remarks\n * This method allows creating parameterized test suites from arrays of values.\n * Each array provided as a case will be passed to the describe callback as separate arguments.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the parameters in each row as function arguments.\n * - timeout (optional): Number - Time in milliseconds to wait for each row before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('addition: %d + %d = %d', (a, b, expected) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends Array<unknown> | [ unknown ]>(...cases: T[]): DescribeCallbackType<T>; // array\n\n /**\n * Creates parameterized test suites from individual test case values.\n *\n * @template T - The type of test case values (objects or primitives)\n *\n * @param args - Individual test case values to be used in the test suites\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the test cases have incompatible types\n *\n * @remarks\n * This method allows creating parameterized test suites from individual values.\n * Each value provided as an argument will be passed to the describe callback.\n * This overload is particularly useful for objects and primitive values.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the test case value as an argument.\n * - timeout (optional): Number - Time in milliseconds to wait for each test case before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * { a: 1, b: 1, expected: 2 },\n * { a: 1, b: 2, expected: 3 },\n * { a: 2, b: 2, expected: 4 }\n * )('addition: $a + $b = $expected', ({ a, b, expected }) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T>(...args: readonly T[]): DescribeCallbackType<T>; // object, and primitives\n\n /**\n * Creates parameterized test suites from individual objects or primitive values.\n *\n * @template T - The type of test case values\n *\n * @param args - Individual objects or primitive values to be used as test cases\n *\n * @returns A callback function compatible with Jest's describe method\n *\n * @remarks\n * This method creates parameterized test suites where each argument represents a complete test case.\n * Useful for testing with objects or primitive values that each represent a single test scenario.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the test case value as an argument.\n * - timeout (optional): Number - Time in milliseconds to wait for each test case before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * { input: 'hello', expected: 'HELLO' },\n * { input: 'world', expected: 'WORLD' }\n * )('toUpperCase($input) \u2192 $expected', (testCase) => {\n * test('converts correctly', () => {\n * expect(testCase.input.toUpperCase()).toBe(testCase.expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends Array<unknown>>(...args: T): DescribeCallbackType<T[number]>; // primitives\n\n /**\n * Creates parameterized test suites by delegating to the external 'each' function.\n *\n * @param args - Test case values to be used in the parameterized test suites\n *\n * @returns A callback function compatible with Jest's describe method\n *\n * @remarks\n * This method serves as a bridge between the describe context and the external 'each' utility.\n * It binds the current context's 'invoke' method and passes it along with the test cases\n * to the external 'each' function, which handles the creation of parameterized test suites.\n *\n * The returned function has the same behavior as the one returned by the external 'each' function,\n * but ensures that tests are executed within the proper describe context.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block, which can include parameter placeholders\n * - fn: Function - The describe callback function that will receive the test case values\n * - timeout (optional): Number - Time in milliseconds before test timeout\n *\n * @example\n * ```ts\n * // Internal implementation used when calling describe.each\n * // Users don't directly call this method, but rather use:\n * describe.each([1, 2, 3])('test with %d', (num) => {\n * test('works with ' + num, () => {\n * expect(num).toBeDefined();\n * });\n * });\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n each(...args: Array<unknown>): DescribeCallbackType<unknown> {\n return each(this.invoke.bind(this), ...args);\n }\n\n /**\n * Executes a describe block with the given description and function.\n *\n * @param description - The title of the describe block\n * @param block - The function containing the tests to be run within this describe block\n * @param args - Optional array of arguments to pass to the block function\n *\n * @throws Error - When attempting to nest a describe block inside a test\n *\n * @remarks\n * This method is the core implementation for creating test suites in the testing framework.\n * It registers a describe block with the suite state manager and applies any options\n * that were set on the describe object before this method was called.\n *\n * This method is primarily called internally by the testing framework and\n * typically not meant to be called directly by users.\n *\n * @example\n * ```ts\n * // Internal implementation example - not for direct use\n * const describeObj = new Describe();\n * describeObj.invoke('My test suite', () => {\n * // Test implementations\n * });\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n invoke(description: string, block: FunctionType, args: Array<unknown> = []): void {\n const suiteState = inject(SuiteState);\n const runningTest = suiteState.test;\n\n if (runningTest) {\n throw new Error(\n `Cannot nest a describe inside a test '${ description }' in '${ runningTest.description }'`\n );\n }\n\n suiteState.addDescribe(description, block, this.options, args);\n // Reset options after use\n this.options = {};\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ContextType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { CallbackHandlerType } from '@shared/models/interfaces/hook-model.interface';\n\n\n/**\n * Imports\n */\n\nimport { isPromise } from '@remotex-labs/xjet-expect';\nimport { withTimeout } from '@components/timeout.component';\n\n/**\n * Represents a model for managing and executing hook functions with a specified timeout.\n * Provides functionality for associating invocation locations and handling errors during execution.\n *\n * @remarks\n * This class ensures that hooks are executed with proper timeout enforcement\n * and supports both synchronous and asynchronous hook functions.\n * It throws an error if an asynchronous hook\n * incorrectly uses a \"done\" callback or if it fails to complete execution within the specified timeout.\n *\n * @since 1.0.0\n */\n\nexport class HookModel {\n /**\n * Represents the current location of an invocation within the application or a fallback to undefined.\n *\n * @remarks\n * This variable is designed\n * to hold the interface representing the invocation's location for tracking.\n * If no invocation location is available, it defaults to undefined.\n *\n * @since 1.0.0\n */\n\n private location: string = '';\n\n /**\n * Constructs an instance of the class.\n *\n * @param hookFunction - The callback function that will be executed based on specific conditions.\n * @param timeout - The time in milliseconds before the callback function is triggered.\n * @throws Will throw an error if the provided timeout value is negative or invalid.\n *\n * @remarks This constructor sets up the necessary callback function and timeout configuration for the instance.\n *\n * @since 1.0.0\n */\n\n constructor(\n private readonly hookFunction: CallbackHandlerType, private readonly timeout: number\n ) {}\n\n /**\n * Sets the location of the invocation based on the provided location object.\n *\n * @param location - An object implementing the `InvocationLocationType` or `undefined`\n * to reset the location.\n *\n * @remarks\n * This method assigns a new location value to the current location of the invocation.\n * Passing `undefined` will clear the current location.\n *\n * @since 1.0.0\n */\n\n setLocation(location: string): void {\n this.location = location;\n }\n\n /**\n * Executes a hook function with a timeout mechanism.\n *\n * @param context - The context object passed to the hook function, containing execution-specific information.\n * @return A promise that resolves when the hook function completes its execution successfully.\n *\n * @throws TimeoutError - If the hook function does not call `done()` within the specified timeout duration.\n *\n * @remarks This method concurrently runs the hook function and a timeout check, ensuring that execution does not\n * exceed the predefined timeout.\n * If the timeout is reached without the hook function completing, an ` TimeoutError ` is thrown.\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<unknown>): Promise<void> {\n return withTimeout<void>(\n this.executeHook(this.hookFunction, context),\n this.timeout,\n 'hook while waiting for \\'done()\\' to be called.',\n this.location\n );\n }\n\n /**\n * Executes a given hook function, handling both synchronous and asynchronous hooks,\n * with or without a callback mechanism.\n *\n * @param hook - The function representing the hook to be executed.\n * It Can be a synchronous or asynchronous function.\n * @param context - An object to be used as the `this` context\n * when invoking the hook function.\n\n * @remarks This method ensures correct execution and error handling\n * for both callback-based and promise-based hooks.\n *\n * @since 1.0.0\n */\n\n private async executeHook(hook: FunctionType, context: unknown): Promise<void> {\n if (isPromise(hook) && hook.length > 0) {\n throw new Error(`Async hook '${ hook.name }' should not use 'done' callback.`);\n }\n\n if (hook.length > 0) {\n return this.executeCallbackHook(hook, context);\n }\n\n return hook.call(context);\n }\n\n /**\n * Executes a callback-style hook by wrapping it in a Promise\n *\n * @param hook - The callback hook function to execute\n * @param context - Execution context to bind to the hook function\n * @returns A Promise that resolves when the hook completes or rejects when it fails\n *\n * @throws Error - When the hook callback is invoked with an error parameter\n *\n * @remarks This method converts traditional Node.js-style callback patterns (error-first callbacks)\n * into Promise-based async/await compatible functions. The hook function receives a done callback\n * as its argument and must call it to signal completion.\n *\n * @example\n * ```ts\n * const callbackHook = (done) => {\n * setTimeout(() => done(), 100);\n * };\n *\n * await executeCallbackHook(callbackHook, this);\n * ```\n *\n * @see isPromise\n * @since 1.0.0\n */\n\n private executeCallbackHook(hook: FunctionType, context: unknown): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n hook.call(context, (error?: string | { message: string }): void => {\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\n\n/**\n * Imports\n */\n\nimport { HookModel } from '@shared/models/hook.model';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { getTrimmedStackString } from '@components/location.component';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\n\n/**\n * Default timeout\n */\n\nconst DEFAULT_TIMEOUT = globalThis.__XJET?.runtime.timeout ?? 5000;\n\n/**\n * Creates and registers a hook with the current test suite\n *\n * @param hookType - Type of hook to register\n * @param callback - Function to execute for this hook\n * @param location - The precise source code location where the error occurred\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @example\n * ```ts\n * createHook(HookType.BEFORE_EACH, () => {\n * // Setup code to run before each test\n * resetTestDatabase();\n * }, 10000);\n * ```\n *\n * @see HookType\n * @see HookModel\n * @see SuiteState\n *\n * @since 1.0.0\n */\n\nexport function createHook(hookType: HookType, callback: FunctionType, location: string, timeout: number = DEFAULT_TIMEOUT): void {\n const hook = new HookModel(callback, timeout);\n hook.setLocation(location);\n inject(SuiteState).describe.addHook(hookType, hook);\n}\n\n/**\n * Registers an after-all hook to be executed once after all tests in a suite have completed\n *\n * @param callback - Function to execute after all tests in the suite\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating AFTER_ALL hooks.\n * After-all hooks are useful for cleanup operations that should occur once after all tests complete.\n *\n * @example\n * ```ts\n * afterAllDirective(() => {\n * // Teardown code to run after all tests\n * disconnectFromDatabase();\n * }, 10000);\n * ```\n *\n * @see createHook\n * @see HookType.AFTER_ALL\n *\n * @since 1.0.0\n */\n\nexport function afterAllDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.AFTER_ALL, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers a before-all hook to be executed once before any tests in a suite run\n *\n * @param callback - Function to execute before any tests in the suite\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating BEFORE_ALL hooks.\n * Before-all hooks are useful for setup operations that should occur once before any tests run.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * beforeAllDirective(() => {\n * // Setup code to run before any tests\n * initializeTestDatabase();\n * }, 10000);\n * ```\n *\n * @see createHook\n * @see HookType.BEFORE_ALL\n *\n * @since 1.0.0\n */\n\nexport function beforeAllDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.BEFORE_ALL, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers an after-each hook to be executed after each test in a suite completes\n *\n * @param callback - Function to execute after each test\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating AFTER_EACH hooks.\n * After-each hooks run after each test case and are useful for cleanup operations that should occur\n * after every individual test.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * afterEachDirective(() => {\n * // Cleanup code to run after each test\n * resetTestState();\n * }, 8000);\n * ```\n *\n * @see createHook\n * @see HookType.AFTER_EACH\n *\n * @since 1.0.0\n */\n\nexport function afterEachDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.AFTER_EACH, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers a before-each hook to be executed before each test in a suite runs\n *\n * @param callback - Function to execute before each test\n * @param timeout - Maximum execution time in milliseconds\n *\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating BEFORE_EACH hooks.\n * Before-each hooks run before each test case and are useful for setup operations that should occur\n * before every individual test.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * beforeEachDirective(() => {\n * // Setup code to run before each test\n * prepareTestEnvironment();\n * }, 8000);\n * ```\n *\n * @see createHook\n * @see HookType.BEFORE_EACH\n *\n * @since 1.0.0\n */\n\nexport function beforeEachDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.BEFORE_EACH, callback, getTrimmedStackString(), timeout); // Fixed a bug here - was using AFTER_ALL\n}\n"],
6
- "mappings": "s1GAgDA,GAAG,UAAS,CACR,IAAM,SAAW,UAuBX,GAAK,OAAC,YAAgC,CACxC,IAAM,aAAe,SAAS,QAAQ,UAAU,EAC1C,QAAU,SAAS,UAAU,EAC7B,SAAW,SAAS,MAAM,YAAY,EAC5C,GAAI,CAAC,UAAY,SAAS,SAAU,OAAO,QAE3C,IAAI,OACJ,OAAI,OAAO,SAAS,SAAY,WAC5B,OAAS,SAAS,QACX,OAAO,SAAS,SAAY,UAAY,SAAS,UAAY,KACpE,OAAS,CAAE,GAAG,SAAS,OAAQ,EAE/B,OAAS,SAAS,QAGtB,SAAS,QAAU,OACnB,SAAS,SAAW,GAEb,MACX,EAnBW,MAqBX,OAAO,OAAO,GAAI,QAAQ,EAC1B,WAAW,QAAU,EACzB,CC1FA,OAAS,YAAe,4BCkB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error", "serializeError", "error", "error", "serializeError", "LogLevel", "error", "target", "mock", "_init", "error", "isPromise", "isPromise", "error"]
4
+ "sourceRoot": "https://github.com/remotex-lab/xJet/tree/v1.3.4/",
5
+ "sourcesContent": ["/**\n * Import will remove at compile time\n */\n\nimport type { Module } from 'module';\n\n/**\n * Module interception utility that enhances Node.js requires {@link NodeJS.Require} functionality to enable mocking.\n *\n * @remarks\n * This module replaces the global `require` function with an enhanced version that:\n * - Logs all module import operations for debugging\n * - Creates shallow copies of object exports to enable property overriding\n * - Maintains original function references for direct function exports\n * - Provides a foundation for runtime module mocking and testing\n *\n * The primary purpose is to make modules mockable by ensuring that object exports\n * can be modified without affecting the original cached module, enabling test doubles\n * and dependency injection in testing environments.\n *\n * Responsibilities:\n * - Module loading tracking\n * - Export transformation for mockability\n * - Cache management\n * - Internal module protection\n *\n * @example\n * ```ts\n * // Import this module at the entry point before any other imports\n * import './require-interceptor';\n *\n * // Now you can mock modules by overriding properties\n * const fs = require('fs');\n * fs.readFileSync = jest.fn().mockReturnValue('mocked content');\n *\n * // Or you can mock getter-based modules like esbuild\n * const esbuild = require('esbuild');\n * Object.defineProperty(esbuild, 'build', {\n * get: () => jest.fn().mockResolvedValue({ errors: [], warnings: [] })\n * });\n * ```\n *\n * @see Module\n * @see NodeJS.Require\n *\n * @since 1.2.2\n */\n\nif(require) {\n const original = require;\n\n /**\n * Enhanced requires function that wraps the original Node.js `require` to enable mocking.\n *\n * @param moduleName - The name or path of the module to require\n * @returns The exports from the required module, possibly transformed for mockability\n *\n * @remarks\n * This function intercepts all `require` calls and transforms module exports to make them\n * mockable:\n *\n * - Function exports are returned directly (can be mocked via function replacement)\n * - Object exports are shallow-cloned to enable property overriding without affecting the cache\n * - Modules with getter properties (like esbuild) can be mocked by redefining property descriptors\n * - Primitive exports are passed through unchanged\n *\n * The transformation creates a layer of indirection that allows tests to replace\n * or modify functionality without permanently altering the module cache.\n *\n * @since 1.2.2\n */\n\n const fn = (moduleName: string): unknown => {\n const resolvedPath = original.resolve(moduleName);\n const exports = original(moduleName);\n const resolved = original.cache[resolvedPath] as (Module & { internal?: boolean }) | undefined;\n if (!resolved || resolved.internal) return exports;\n\n let result: unknown;\n if (typeof resolved.exports === 'function') {\n result = resolved.exports;\n } else if (typeof resolved.exports === 'object' && resolved.exports !== null) {\n result = { ...resolved.exports };\n } else {\n result = resolved.exports;\n }\n\n resolved.exports = result;\n resolved.internal = true;\n\n return result;\n };\n\n Object.assign(fn, original);\n globalThis.require = fn as typeof require;\n}\n", "/**\n * Imports\n */\n\nimport '@shared/components/require.component';\nimport { xExpect } from '@remotex-labs/xjet-expect';\nimport { MockState } from '@shared/states/mock.state';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport * as logging from '@shared/components/log.component';\nimport { spyOnImplementation } from '@shared/mock/spy.mock';\nimport * as FakeTimer from '@shared/services/timer.service';\nimport { TestDirective } from '@shared/directives/test.directive';\nimport { DescribeDirective } from '@shared/directives/describe.directive';\nimport { fnImplementation, mockImplementation } from '@shared/mock/fn.mock';\nimport { afterAllDirective, afterEachDirective } from '@shared/directives/hook.directive';\nimport { beforeAllDirective, beforeEachDirective } from '@shared/directives/hook.directive';\n\n/**\n * Clears the specified mock method on all registered mocks\n *\n * @param method - The method name to clear on all mock instances\n *\n * @throws TypeError - When called with an invalid method name\n *\n * @remarks\n * This utility function iterates through all mocks registered in the MockState\n * and calls the specified method on each one, effectively performing a batch operation\n * across all mock instances.\n *\n * @example\n * ```ts\n * // Clear all recorded calls on all mocks\n * clearMocks('resetHistory');\n *\n * // Reset behavior on all mocks\n * clearMocks('resetBehavior');\n * ```\n *\n * @see MockState\n *\n * @since 1.0.0\n */\n\nfunction clearMocks(method: keyof MockState): void {\n MockState.mocks.forEach((mock) => {\n const instance = mock.deref();\n if(!instance) {\n return MockState.mocks.delete(mock);\n }\n\n instance[method]();\n });\n}\n\n/**\n * Set global\n */\n\nconst setupGlobals = (): void => {\n const globals = globalThis as { [key: string]: unknown; };\n\n globals.xJet = {\n /**\n * Mock\n */\n\n fn: fnImplementation,\n mock: mockImplementation,\n spyOn: spyOnImplementation,\n clearAllMocks: (): void => clearMocks('mockClear'),\n resetAllMocks: (): void => clearMocks('mockReset'),\n restoreAllMocks: (): void => clearMocks('mockRestore'),\n\n /**\n * Logs\n */\n\n log: logging.log,\n info: logging.info,\n warn: logging.warn,\n error: logging.error,\n debug: logging.debug,\n\n /**\n * Timers\n */\n\n runAllTimers: FakeTimer.runAllTimers,\n useFakeTimers: FakeTimer.useFakeTimers,\n useRealTimers: FakeTimer.useRealTimers,\n clearAllTimers: FakeTimer.clearAllTimers,\n runAllTimersAsync: FakeTimer.runAllTimersAsync,\n advanceTimersByTime: FakeTimer.advanceTimersByTime,\n runOnlyPendingTimers: FakeTimer.runOnlyPendingTimers,\n runOnlyPendingTimersAsync: FakeTimer.runOnlyPendingTimersAsync\n };\n\n globals.expect = xExpect;\n globals.state = inject(SuiteState);\n globals.it = TestDirective.getInstance();\n globals.test = TestDirective.getInstance();\n globals.describe = DescribeDirective.getInstance();\n globals.afterAll = afterAllDirective;\n globals.beforeAll = beforeAllDirective;\n globals.afterEach = afterEachDirective;\n globals.beforeEach = beforeEachDirective;\n};\n\nsetupGlobals();\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { PromiseValueType } from '@shared/states/interfaces/mock-state.interface';\nimport type { BoundInterface } from '@shared/components/interfaces/polyfill-component.interface';\nimport type { MockInvocationResultInterface } from '@shared/states/interfaces/mock-state.interface';\nimport type { ImplementationType, MocksStateInterface } from '@shared/states/interfaces/mock-state.interface';\n\n/**\n * @template DEFAULT_MOCK_NAME\n * A constant that holds the default name used for mocking purposes.\n * It is commonly used in testing scenarios to provide a standard mock identifier.\n *\n * @remarks\n * The value of `DEFAULT_MOCK_NAME` is set to 'xJet.mock()'. It is recommended\n * to use this variable as the default name to maintain consistency across\n * mock-related functionalities in your application.\n *\n * @since 1.0.0\n */\n\nconst DEFAULT_MOCK_NAME = 'xJet.mock()';\n\n/**\n * A powerful mock state manager for simulating functions and classes in tests.\n *\n * @template F - The function signature being mocked, defaults to any function\n *\n * @remarks\n * MockState provides a complete mocking solution. It tracks\n * all invocations, including arguments, return values, and contexts, while also allowing\n * customization of behavior through various methods like `mockImplementation` and\n * `mockReturnValue`.\n *\n * Key features:\n * - Tracks call arguments, return values, and execution contexts\n * - Supports one-time implementations and return values\n * - Manages Promise resolutions and rejections\n * - Provides methods for resetting or restoring mock state\n * - Preserves the interface of the original function\n *\n * @example\n * ```ts\n * // Create a basic mock\n * const mockFn = new MockState();\n *\n * // Configure return values\n * mockFn.mockReturnValue('default');\n * mockFn.mockReturnValueOnce('first call');\n *\n * // Use the mock\n * console.log(mockFn()); // 'first call'\n * console.log(mockFn()); // 'default'\n *\n * // Inspect calls\n * console.log(mockFn.mock.calls); // [[], []]\n * ```\n *\n * @since 1.0.0\n */\n\nexport class MockState<F extends FunctionType = FunctionType> extends Function {\n /**\n * List of all mocks that created as WeakRef\n */\n\n static mocks: Set<WeakRef<MockState>> = new Set();\n\n /**\n * The `name` property represents the name of the mock function.\n */\n\n override name: string;\n\n /**\n * Flag to detect mock functions\n */\n\n readonly xJetMock: boolean = true;\n\n /**\n * Holds the current state of the mock, including all invocation records.\n *\n * @remarks\n * This property tracks the complete history of the mock's usage, storing\n * information like call arguments, return values, execution contexts,\n * instances, and the order of invocations.\n *\n * It's initialized with empty arrays for tracking and gets updated with\n * each invocation. This state is what powers the inspection capabilities\n * accessible via the public `mock` getter.\n *\n * @since 1.0.0\n */\n\n private state: MocksStateInterface<F>;\n\n /**\n * Stores one-time implementations to be used on successive invocations.\n *\n * @remarks\n * This queue contains functions that will be consumed in FIFO order\n * (first-in, first-out) when the mock is called. Each implementation\n * is used exactly once and then removed from the queue.\n *\n * When adding implementations with `mockImplementationOnce()` or similar\n * methods, they are pushed to this queue. On invocation, the mock will\n * check this queue first, using and removing the oldest implementation\n * if available, or falling back to the default implementation.\n *\n * @since 1.0.0\n */\n\n private queuedImplementations: Array<ImplementationType<F>> = [];\n\n /**\n * The current default implementation for this mock.\n *\n * @remarks\n * This property holds the function that will be executed when the mock is called,\n * unless overridden by a queued one-time implementation. It can be set using\n * the `mockImplementation()` method and retrieved with `getMockImplementation()`.\n *\n * If not explicitly set, it defaults to `undefined`, meaning the mock will\n * return `undefined` when called (after any queued implementations are used).\n *\n * This implementation determines the behavior of the mock for all calls that\n * don't have a specific one-time implementation in the queue.\n *\n * @since 1.0.0\n */\n\n private implementation: ImplementationType<F> | undefined;\n\n /**\n * Preserves the original implementation provided when creating the mock.\n *\n * @remarks\n * This property stores the initial function passed to the constructor, allowing\n * the mock to be restored to its original behavior later using `mockRestore()`.\n *\n * If no implementation was provided in the constructor, this will contain a\n * function that returns `undefined` when called.\n *\n * The original implementation is immutable and serves as a reference point\n * for resetting the mock to its initial state.\n *\n * @since 1.0.0\n */\n\n private readonly originalImplementation: ImplementationType<F>;\n\n /**\n * Optional cleanup function to be called when the mock is restored.\n *\n * @remarks\n * If provided, this function will be executed when `mockRestore()` is called,\n * allowing for custom cleanup operations. This is particularly useful when\n * creating mocks that replace methods or properties on existing objects.\n *\n * The restore function should handle any necessary teardown, such as\n * restoring original object properties, removing event listeners, or\n * closing connections that were established during mock creation.\n *\n * @since 1.0.0\n */\n\n private readonly restore?: () => F | void;\n\n /**\n * Creates a new instance of a mock function.\n *\n * @template F - The function type being mocked. This generic type parameter allows\n * the mock to properly type-check parameters and return values to match\n * the function signature being mocked.\n *\n * @param implementation - The initial function implementation to use. If not provided,\n * the mock will return `undefined` when called.\n * @param restore - Optional cleanup function that will be called when `mockRestore()` is invoked.\n * Useful for restoring original behavior when mocking existing object methods.\n * @param name - Optional name for the mock function, used in error messages and test output.\n * Defaults to \"xJet.fn()\" if not provided.\n *\n * @remarks\n * The constructor initializes the mock's state, implementation, and metadata.\n * It returns a Proxy that allows the mock to be both a function and an object with properties.\n *\n * The Proxy intercepts:\n * - Function calls (via `apply`)\n * - Property access (via `get`)\n * - Constructor calls with `new` (via `construct`)\n *\n * This enables the mock to track calls, return configured values, and provide\n * helper methods for assertions and configuration.\n *\n * @see ReturnType\n * @see ImplementationType\n *\n * @since 1.0.0\n */\n\n constructor(implementation?: F, restore?: () => F | void, name?: string) {\n super();\n this.name = name ?? DEFAULT_MOCK_NAME;\n this.state = this.initState();\n this.implementation = implementation || undefined;\n\n this.restore = restore;\n this.originalImplementation = implementation || ((): ReturnType<F> => <ReturnType<F>> undefined);\n\n return <this> new Proxy(this, {\n get: this.invokeGet,\n apply: this.invokeFunction,\n construct: <ProxyHandler<object>['construct']> this.invokeClass\n });\n }\n\n /**\n * Gets a readonly snapshot of the current mocks state.\n *\n * @template F - The function type being mocked.\n *\n * @returns A frozen (immutable) copy of the mock state {@link MocksStateInterface}, containing information\n * about calls, return values, and other tracking data.\n *\n * @remarks\n * This property provides safe access to the mock's internal state for assertions and\n * debugging purposes. The returned object is a deep copy with all properties frozen\n * to prevent accidental modification of the mock's internal state.\n *\n * @see MocksStateInterface\n *\n * @since 1.0.0\n */\n\n get mock(): Readonly<MocksStateInterface<F>> {\n return Object.freeze({ ...this.state });\n }\n\n /**\n * Gets the original function implementation.\n *\n * @template F - The function type being mocked.\n *\n * @returns The original function implementation that was provided when creating the mock\n * or a default implementation that returns undefined if none was provided.\n *\n * @remarks\n * This property allows access to the original implementation that was stored\n * when the mock was created. It's useful when you need to temporarily access\n * or call the original behavior within test cases.\n *\n * @example\n * ```ts\n * // Create a mock with an original implementation\n * const originalFn = (x: number) => x * 2;\n * const mockFn = xJet.fn(originalFn);\n *\n * // Override the implementation for some tests\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * // Call the original implementation directly when needed\n * const result = mockFn.original(5); // Returns 10, not 15\n * ```\n *\n * @since 1.0.0\n */\n\n get original(): F {\n return <F> this.originalImplementation;\n }\n\n /**\n * Clears all information stored in the mock's state {@link MocksStateInterface}.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method resets all stored information such as tracked calls, return values,\n * and other state information. It doesn't reset any custom implementations that\n * were set using mockImplementation or similar methods.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n * mockFn('first call');\n * mockFn('second call');\n *\n * expect(mockFn.mock.calls.length).toBe(2);\n *\n * mockFn.mockClear();\n *\n * // All calls information has been cleared\n * expect(mockFn.mock.calls.length).toBe(0);\n * ```\n *\n * @since 1.0.0\n */\n\n mockClear(): this {\n this.state = this.initState();\n\n return this;\n }\n\n /**\n * Resets the mock by clearing all state and removing all queued implementations.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method performs a more complete reset than mockClear() {@link mockClear}.\n * It clears all stored information about calls and additionally removes any queued implementations that were\n * set using mockImplementationOnce(). The default implementation will be restored.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n * mockFn.mockImplementationOnce(() => 'first call');\n * mockFn.mockImplementationOnce(() => 'second call');\n *\n * console.log(mockFn()); // 'first call'\n *\n * mockFn.mockReset();\n *\n * // All calls have been cleared, and queued implementations removed\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockClear\n * @since 1.0.0\n */\n\n mockReset(): this {\n this.mockClear();\n this.queuedImplementations = [];\n\n return this;\n }\n\n /**\n * Restores the original implementation of the mocked function.\n *\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method performs the most complete reset operation. It first calls mockReset() {@link mockReset}\n * to clear all state and queued implementations, then restores the original implementation\n * provided when the mock was created. If a custom restore function was provided,\n * it will be used instead to determine the implementation to restore.\n *\n * @example\n * ```ts\n * // Create a mock with an original implementation\n * const originalFn = (x: number) => x * 2;\n * const mockFn = xJet.fn(originalFn);\n *\n * // Override the implementation\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * console.log(mockFn(5)); // 15\n *\n * // Restore the original implementation\n * mockFn.mockRestore();\n *\n * console.log(mockFn(5)); // 10\n * ```\n *\n * @see mockClear\n * @see mockReset\n *\n * @since 1.0.0\n */\n\n mockRestore(): this {\n this.mockReset();\n const restore = this.restore?.();\n if (typeof restore === 'function') this.implementation = restore;\n else this.implementation = this.originalImplementation;\n\n return this;\n }\n\n /**\n * Returns the current implementation of the mock function.\n *\n * @returns The current mock implementation, or undefined if no implementation exists.\n *\n * @remarks\n * This method returns the current implementation function used by the mock.\n * This could be the default implementation, a custom implementation set via\n * mockImplementation() {@link mockImplementation}, or the original implementation\n * if mockRestore() {@link mockRestore} was called.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * // Get the default implementation\n * const impl = mockFn.getMockImplementation();\n * console.log(impl()); // 'default'\n *\n * // Change the implementation\n * mockFn.mockImplementation(() => 'new implementation');\n *\n * // Get the new implementation\n * const newImpl = mockFn.getMockImplementation();\n * console.log(newImpl()); // 'new implementation'\n * ```\n *\n * @since 1.0.0\n */\n\n getMockImplementation(): ImplementationType<F> | undefined {\n return this.implementation;\n }\n\n /**\n * Returns the next implementation to be used when the mock is called.\n *\n * @returns The next implementation from the queue, or the default implementation if the queue is empty.\n *\n * @remarks\n * This method retrieves and removes the next implementation from the queue of implementations\n * added via mockImplementationOnce() {@link mockImplementationOnce}. If the queue is empty,\n * it returns the default implementation set via mockImplementation() {@link mockImplementation}\n * or the original function.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n * mockFn.mockImplementationOnce(() => 'first call');\n * mockFn.mockImplementationOnce(() => 'second call');\n *\n * const firstImpl = mockFn.getNextImplementation();\n * console.log(firstImpl()); // 'first call'\n *\n * const secondImpl = mockFn.getNextImplementation();\n * console.log(secondImpl()); // 'second call'\n *\n * const defaultImpl = mockFn.getNextImplementation();\n * console.log(defaultImpl()); // 'default'\n * ```\n *\n * @since 1.0.0\n */\n\n getNextImplementation(): ImplementationType<F> | undefined {\n return this.queuedImplementations.length ? this.queuedImplementations.shift() : this.implementation;\n }\n\n /**\n * Sets a new implementation for this mock function.\n *\n * @param fn - The function to be used as the mock implementation.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method sets a persistent implementation that will be used whenever the mock function is called,\n * unless there are queued implementations from mockImplementationOnce() {@link mockImplementationOnce}.\n * The implementation remains until it is replaced by another call to mockImplementation() or restored\n * via mockRestore() {@link mockRestore}.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockImplementation((x: number) => x * 2);\n *\n * console.log(mockFn(5)); // 10\n * console.log(mockFn(10)); // 20\n *\n * // Change the implementation\n * mockFn.mockImplementation((x: number) => x * 3);\n *\n * console.log(mockFn(5)); // 15\n * ```\n *\n * @see mockRestore\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockImplementation(fn: ImplementationType<F>): this {\n this.implementation = fn;\n\n return this;\n }\n\n /**\n * Adds a one-time implementation for this mock function.\n *\n * @param fn - The function to be used as the mock implementation for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method queues an implementation that will be used for a single call to the mock function.\n * After being used once, it will be removed from the queue. Multiple implementations can be queued,\n * and they will be used in the order they were added. Once all queued implementations are used,\n * the mock will revert to using the implementation set by mockImplementation() {@link mockImplementation}.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * mockFn.mockImplementationOnce(() => 'first call')\n * .mockImplementationOnce(() => 'second call');\n *\n * console.log(mockFn()); // 'first call'\n * console.log(mockFn()); // 'second call'\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockReset\n * @see mockImplementation\n *\n * @since 1.0.0\n */\n\n mockImplementationOnce(fn: ImplementationType<F>): this {\n this.queuedImplementations.push(fn);\n\n return this;\n }\n\n /**\n * Sets a fixed return value for this mock function.\n *\n * @param value - The value to be returned when the mock function is called.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper around mockImplementation() {@link mockImplementation}\n * that creates an implementation which always returns the same value. It replaces any existing\n * implementation with a function that simply returns the specified value.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockReturnValue(42);\n *\n * console.log(mockFn()); // 42\n * console.log(mockFn('anything')); // 42\n * console.log(mockFn({}, [])); // 42\n *\n * // Can be changed\n * mockFn.mockReturnValue('new value');\n * console.log(mockFn()); // 'new value'\n * ```\n *\n * @see mockImplementation\n * @see mockReturnValueOnce\n *\n * @since 1.0.0\n */\n\n mockReturnValue(value: ReturnType<F>): this {\n this.mockImplementation(() => value);\n\n return this;\n }\n\n /**\n * Adds a one-time fixed return value for this mock function.\n *\n * @param value - The value to be returned for a single call to the mock function.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper around mockImplementationOnce() {@link mockImplementationOnce}\n * that creates a one-time implementation which returns the specified value. Multiple return values\n * can be queued, and they will be used in the order they were added. After all queued values are\n * consumed, the mock will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => 'default');\n *\n * mockFn.mockReturnValueOnce(42)\n * .mockReturnValueOnce('string value')\n * .mockReturnValueOnce({ object: true });\n *\n * console.log(mockFn()); // 42\n * console.log(mockFn()); // 'string value'\n * console.log(mockFn()); // { object: true }\n * console.log(mockFn()); // 'default'\n * ```\n *\n * @see mockReturnValue\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockReturnValueOnce(value: ReturnType<F>): this {\n this.mockImplementationOnce(() => value);\n\n return this;\n }\n\n /**\n * Sets a resolved Promise return value for this mock function.\n *\n * @param value - The value that the Promise will resolve to.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates an implementation which returns a\n * Promise that resolves to the specified value. It's particularly useful for testing\n * async functions that should return resolved Promises.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockResolvedValue('resolved value');\n *\n * // The mock now returns a Promise that resolves to 'resolved value'\n * mockFn().then(result => {\n * console.log(result); // 'resolved value'\n * });\n *\n * // Can also be used with async/await\n * const result = await mockFn();\n * console.log(result); // 'resolved value'\n * ```\n *\n * @see mockRejectedValue\n * @see mockImplementation\n * @see mockResolvedValueOnce\n *\n * @since 1.0.0\n */\n\n mockResolvedValue(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementation(() => <ReturnType<F>> Promise.resolve(value));\n\n return this;\n }\n\n /**\n * Adds a one-time resolved Promise return value for this mock function.\n *\n * @param value - The value that the Promise will resolve to for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates a one-time implementation which returns\n * a Promise that resolves to the specified value. Multiple resolved values can be queued and\n * will be used in the order they were added. After all queued values are consumed, the mock\n * will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => Promise.resolve('default'));\n *\n * mockFn.mockResolvedValueOnce('first call')\n * .mockResolvedValueOnce('second call')\n * .mockResolvedValueOnce('third call');\n *\n * // Each call returns a different Promise\n * await expect(mockFn()).resolves.toEqual('first call');\n * await expect(mockFn()).resolves.toEqual('second call');\n * await expect(mockFn()).resolves.toEqual('third call');\n * await expect(mockFn()).resolves.toEqual('default');\n * ```\n *\n * @see mockResolvedValue\n * @see mockRejectedValueOnce\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockResolvedValueOnce(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementationOnce(() => <ReturnType<F>> Promise.resolve(value));\n\n return this;\n }\n\n /**\n * Sets a rejected Promise return value for this mock function.\n *\n * @param value - The error that the Promise will reject with.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates an implementation which returns a\n * Promise that rejects with the specified value. It's particularly useful for testing\n * error handling in async functions.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn();\n *\n * mockFn.mockRejectedValue(new Error('Something went wrong'));\n *\n * // The mock now returns a Promise that rejects with the error\n * mockFn().catch(error => {\n * console.error(error.message); // 'Something went wrong'\n * });\n *\n * // Can also be used with async/await and try/catch\n * try {\n * await mockFn();\n * } catch (error) {\n * console.error(error.message); // 'Something went wrong'\n * }\n * ```\n *\n * @see mockResolvedValue\n * @see mockImplementation\n * @see mockRejectedValueOnce\n *\n * @since 1.0.0\n */\n\n mockRejectedValue(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementation(() => <ReturnType<F>> Promise.reject(value));\n\n return this;\n }\n\n /**\n * Adds a one-time rejected Promise return value for this mock function.\n *\n * @param value - The error that the Promise will reject with for a single call.\n * @returns The mock instance for method chaining.\n *\n * @remarks\n * This method is a convenience wrapper that creates a one-time implementation which returns\n * a Promise that rejects with the specified value. Multiple rejected values can be queued and\n * will be used in the order they were added. After all queued values are consumed, the mock\n * will revert to its default implementation.\n *\n * @example\n * ```ts\n * const mockFn = xJet.fn(() => Promise.resolve('success'));\n *\n * mockFn.mockRejectedValueOnce(new Error('first error'))\n * .mockRejectedValueOnce(new Error('second error'));\n *\n * // First call rejects with 'first error'\n * await expect(mockFn()).rejects.toThrow('first error');\n *\n * // Second call rejects with 'second error'\n * await expect(mockFn()).rejects.toThrow('second error');\n *\n * // Third call uses the default implementation and resolves\n * await expect(mockFn()).resolves.toEqual('success');\n * ```\n *\n * @see mockRejectedValue\n * @see mockResolvedValueOnce\n * @see mockImplementationOnce\n *\n * @since 1.0.0\n */\n\n mockRejectedValueOnce(value: PromiseValueType<ReturnType<F>>): this {\n this.mockImplementationOnce(() => <ReturnType<F>> Promise.reject(value));\n\n return this;\n }\n\n /**\n * Custom inspection method for Node.js util.inspect().\n *\n * @returns A string representation of this mock constructor.\n *\n * @remarks\n * This method implements the Node.js custom inspection protocol by using the\n * Symbol.for('nodejs.util.inspect.custom') symbol. When the mock is inspected\n * using util.inspect() or displayed in a Node.js REPL, this custom string\n * representation will be used instead of the default object inspection.\n *\n * @example\n * ```ts\n * const mockConstructor = xJet.fn();\n * console.log(mockConstructor); // Outputs: <Mock Constructor undefined>\n *\n * const namedMock = xJet.fn().mockName('myMock');\n * console.log(namedMock); // Outputs: <Mock Constructor myMock>\n * ```\n *\n * @see https://nodejs.org/api/util.html#util_custom_inspection_functions_on_objects\n *\n * @since 1.0.0\n */\n\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return `<Mock Constructor ${ this.name }>`;\n }\n\n /**\n * Initializes the internal state object for the mock function.\n *\n * @returns A new mock state object with default empty values.\n *\n * @remarks\n * This private method creates and returns a fresh state object used to track\n * mock function invocations. The state includes:\n * - calls: Arguments passed to the mock function\n * - results: Return values or errors from each call\n * - lastCall: Arguments from the most recent call\n * - contexts: 'this' context values for each call\n * - instances: Objects created when the mock is used as a constructor\n * - invocationCallOrder: Tracking the sequence of calls across multiple mocks\n *\n * This method is used internally when creating a new mock or when resetting\n * an existing mocks state.\n *\n * @since 1.0.0\n */\n\n private initState(): MocksStateInterface<F> {\n return {\n calls: [],\n results: [],\n lastCall: undefined,\n contexts: [],\n instances: [],\n invocationCallOrder: []\n };\n }\n\n /**\n * Invokes the mock function with the provided arguments and context.\n *\n * @param thisArg - The 'this' context for the function call\n * @param args - The arguments to pass to the function\n * @returns The result of the mock implementation or undefined\n *\n * @remarks\n * This private method handles the actual invocation of the mock function and manages all\n * state trackings.\n *\n * This method is central to the mock's functionality, enabling call tracking,\n * result recording, and the execution of custom implementations.\n *\n * @since 1.0.0\n */\n\n private invoke(thisArg: ThisParameterType<F>, args: Parameters<F>): ReturnType<F> | undefined {\n let thisContext = thisArg;\n const impl = <FunctionType & BoundInterface> this.getNextImplementation();\n\n const argsArray = <Parameters<F>> args;\n if (typeof impl === 'function') {\n if (impl.__boundArgs) argsArray.unshift(...impl.__boundArgs);\n if (impl.__boundThis) thisContext = <ThisParameterType<F>> impl.__boundThis;\n }\n\n this.state.calls.push(argsArray);\n this.state.contexts.push(<ThisParameterType<F>> thisContext);\n this.state.invocationCallOrder.push(this.state.invocationCallOrder.length + 1);\n\n let result: MockInvocationResultInterface<ReturnType<F>>;\n const index = this.state.results.push({ value: undefined, type: 'incomplete' }) - 1;\n\n if (impl) {\n try {\n const value = impl.call(<ThisParameterType<F>> thisArg, ...args);\n result = { type: 'return', value };\n } catch (error) {\n result = { value: error, type: 'throw' };\n }\n } else {\n result = { type: 'return', value: undefined };\n }\n\n this.state.lastCall = args;\n this.state.results[index] = result;\n\n return <ReturnType<F>> result.value;\n }\n\n /**\n * Handles property access for the mock function proxy.\n *\n * @param target - The mock function instance\n * @param property - The property name or symbol being accessed\n * @returns The property value from either the mock or the original implementation\n *\n * @remarks\n * This private method is used as the 'get' trap for the Proxy surrounding the mock function.\n * It provides property access fallback behavior - first checking if the property exists\n * on the mock itself, and if not, retrieving it from the original implementation.\n *\n * This enables the mock to maintain its own properties while still allowing access to\n * properties from the original function, providing a more transparent mocking experience.\n *\n * @since 1.0.0\n */\n\n private invokeGet(target: this, property: string | symbol): unknown {\n const isProperty = Reflect.has(target, property);\n if (isProperty) return Reflect.get(target, property);\n\n return Reflect.get(target.originalImplementation, property);\n }\n\n /**\n * Handles constructor invocation when the mock is used with 'new'.\n *\n * @param target - The mock function instance\n * @param argArray - The arguments passed to the constructor\n * @param newTarget - The constructor that was directly invoked\n * @returns The constructed instance\n *\n * @remarks\n * This method is used as the 'construct' trap for the Proxy surrounding the mock function.\n * It delegates to the `invoke` method to handle the actual function call, then tracks the\n * resulting instance in the mock's state for later verification.\n *\n * The method handles both cases where the constructor returns an object (which becomes the\n * instance) and where it doesn't (in which case the newTarget becomes the instance).\n *\n * @since 1.0.0\n */\n\n private invokeClass(target: this, argArray: Parameters<F>, newTarget: object): object {\n const result = target.invoke.call(target, <ThisParameterType<F>> newTarget, argArray);\n const isClassInstance = typeof result === 'object' && result !== null && 'constructor' in result;\n target.state.instances.push(isClassInstance ? <ThisParameterType<F>> result : <ThisParameterType<F>> newTarget);\n\n return typeof result === 'object' ? <object> result : newTarget;\n }\n\n /**\n * Handles function invocation when the mock is called.\n *\n * @param target - The mock function instance\n * @param thisArg - The 'this' context for the function call\n * @param argumentsList - The arguments passed to the function\n * @returns The result of the function invocation\n *\n * @remarks\n * This method is used as the 'apply' trap for the Proxy surrounding the mock function.\n * It captures the calling context in the mock's state for later verification, then\n * delegates to the `invoke` method to handle the actual function call logic.\n *\n * This method is called whenever the mock function is invoked as a regular function\n * (not as a constructor).\n *\n * @since 1.0.0\n */\n\n private invokeFunction(target: this, thisArg: ThisParameterType<F>, argumentsList: Parameters<F>): ReturnType<F> | undefined {\n target.state.instances.push(thisArg);\n\n return target.invoke.call(target, thisArg, argumentsList);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConstructorType } from '@remotex-labs/xjet-expect';\nimport type { InjectableOptionsInterface, TokenElementType } from '@symlinks/interfaces/symlinks.interface';\n\n/**\n * Stores singleton instances of injectable classes.\n *\n * @since 1.0.0\n */\n\nconst SINGLETONS = new Map<ConstructorType, unknown>();\n\n/**\n * Stores metadata for classes marked as injectable via `@Injectable`.\n *\n * @internal\n * @since 1.0.0\n */\n\nconst INJECTABLES = new Map<ConstructorType, InjectableOptionsInterface>();\n\n/**\n * Marks a class as injectable and stores its configuration metadata.\n *\n * @template T - The type of the class instance\n * @template Args - The types of arguments accepted by the constructor, defaults to `unknown[]`\n *\n * @param options - Optional configuration for the injectable, including scope and factory\n *\n * @example\n * ```ts\n * @Injectable({ scope: 'singleton' })\n * class MyService {}\n * ```\n *\n * @see InjectableOptionsInterface\n * @since 1.0.0\n */\n\nexport function Injectable<T = unknown, Args extends Array<unknown> = unknown[]>(options?: InjectableOptionsInterface) {\n return function (target: new (...args: Args) => T): void {\n INJECTABLES.set(target, options || {});\n };\n}\n\n/**\n * Resolves and returns an instance of the given injectable token.\n *\n * @template T - The type of the instance to return\n * @template Args - The types of arguments passed to the constructor or factory\n *\n * @param token - The injectable class or token to resolve\n * @param args - Arguments to pass to the constructor or factory\n *\n * @returns The resolved instance of type `T`\n *\n * @throws Error - If the token is not registered as injectable via `@Injectable`\n *\n * @remarks\n * If the injectable is marked with scope `'singleton'`, the same instance will be returned\n * on the following calls. Otherwise, a new instance is created for each call.\n *\n * @example\n * ```ts\n * const service = inject(MyService);\n * ```\n *\n * @see TokenElementType\n * @since 1.0.0\n */\n\nexport function inject<T, Args extends Array<unknown>>(token: TokenElementType<T, Args>, ...args: Args): T {\n if (SINGLETONS.has(token)) return <T>SINGLETONS.get(token);\n\n const metadata = INJECTABLES.get(token);\n if (!metadata) throw new Error(`Cannot inject ${ token.name } \u2013 not marked @Injectable`);\n\n const instance: T = metadata.factory\n ? <T>metadata.factory(...args)\n : new token(...args);\n\n if (metadata?.scope === 'singleton') {\n SINGLETONS.set(token, instance);\n }\n\n return instance;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { MessageType } from '@messages/constants/report.constant';\nimport type { EmitEventInterface, EmitStatusInterface } from '@shared/services/interfaces/emit-service.interface';\n\n/**\n * Imports\n */\n\nimport { serializeError } from '@remotex-labs/xjet-expect';\nimport { encodePacket, PacketKind } from '@packets/packets.module';\n\n/**\n * Emits a status update packet to the dispatcher.\n *\n * @param type - The {@link MessageType} representing the kind of status (e.g., suite start, suite end).\n * @param notification - The {@link EmitStatusInterface} containing ancestry and description details.\n *\n * @remarks\n * This function encodes the notification into a `PacketKind.Status` packet\n * and sends it via the global `dispatch` mechanism.\n *\n * @see MessageType\n * @see encodePacket\n * @see PacketKind.Status\n * @see EmitStatusInterface\n *\n * @since 1.0.0\n */\n\nexport function emitStatus(type: MessageType, notification: EmitStatusInterface = {}): void {\n dispatch(encodePacket(PacketKind.Status, {\n type: type,\n todo: notification?.todo,\n skipped: notification?.skipped,\n duration: notification?.duration,\n ancestry: notification?.ancestry?.join(','),\n description: notification?.description\n }));\n}\n\n/**\n * Emits an action (event) packet to the dispatcher.\n *\n * @param type - The {@link MessageType} representing the kind of action (e.g., test end, describe end).\n * @param notification - The {@link EmitEventInterface} containing ancestry, description,\n * duration, and possible test errors.\n *\n * @remarks\n * - Errors are serialized with {@link serializeError} before being encoded.\n * - The function encodes the notification into a `PacketKind.Events` packet\n * and sends it via the global `dispatch` mechanism.\n *\n * @see MessageType\n * @see encodePacket\n * @see serializeError\n * @see PacketKind.Events\n * @see EmitEventInterface\n *\n * @since 1.0.0\n */\n\nexport function emitEvent(type: MessageType, notification: EmitEventInterface): void {\n const stringErrors = notification.errors?.map((error: Error) =>\n serializeError(error)\n ) || [];\n\n dispatch(encodePacket(PacketKind.Events, {\n type: type,\n errors: stringErrors.length > 0 ? JSON.stringify(stringErrors) : '',\n ancestry: notification.ancestry.join(''),\n duration: notification.duration,\n description: notification.description\n }));\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketHeaderInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { DecodedPacketType, PacketPayloadMapType } from '@packets/interfaces/packets.interface';\n\n/**\n * Imports\n */\n\nimport { serializeError } from '@remotex-labs/xjet-expect';\nimport { PacketKind } from '@packets/constants/packet-schema.constants';\nimport { errorSchema, headerSchema } from '@packets/schema/packet.schema';\nimport { PacketSchemas } from '@packets/constants/packet-schema.constants';\n\n/**\n * Exports constants\n */\n\nexport * from '@packets/constants/packet-schema.constants';\n\n/**\n * Exports interfaces\n */\n\nexport * from '@packets/interfaces/packets.interface';\nexport * from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Encodes a packet of a given kind into a `Buffer`.\n *\n * @template T - The packet kind (`PacketKind.Log`, `PacketKind.Error`, `PacketKind.Status`, or `PacketKind.Events`)\n *\n * @param kind - The type of packet to encode\n * @param data - Partial data matching the packet type; will be combined with header information\n *\n * @returns A `Buffer` containing the serialized packet\n *\n * @throws Error if the provided `kind` does not correspond to a known packet schema\n *\n * @remarks\n * This function combines a header and the payload according to the packet kind.\n * The header includes the suite ID, runner ID, and a timestamp.\n *\n * @since 1.0.0\n */\n\nexport function encodePacket<T extends PacketKind>(kind: T, data: Partial<PacketPayloadMapType[T]>): Buffer {\n const schema = PacketSchemas[kind];\n if (!schema) throw new Error(`Invalid schema kind: ${ kind }`);\n\n const header: PacketHeaderInterface = {\n kind: kind,\n suiteId: globalThis?.__XJET?.runtime?.suiteId ?? '',\n runnerId: globalThis?.__XJET?.runtime.runnerId ?? '',\n timestamp: (new Date()).toISOString()\n };\n\n return Buffer.concat([\n headerSchema.toBuffer(header),\n schema.toBuffer(data)\n ]);\n}\n\n/**\n * Decodes a packet from a `Buffer` into its corresponding object representation.\n *\n * @template T - The expected packet kind (`PacketKind.Log`, `PacketKind.Error`, `PacketKind.Status`, or `PacketKind.Events`)\n *\n * @param buffer - The buffer containing the encoded packet\n * @returns The decoded packet object, combining the header and payload fields\n *\n * @throws Error if the packet kind is unknown or invalid\n *\n * @remarks\n * Decodes both the header and payload based on the packet kind.\n *\n * @since 1.0.0\n */\n\nexport function decodePacket<T extends PacketKind>(buffer: Buffer): DecodedPacketType<T> {\n let offset = headerSchema.size;\n const header = headerSchema.toObject(buffer, (dynamicOffset: number): void => {\n offset += dynamicOffset;\n });\n\n const type = header.kind as PacketKind;\n const schema = PacketSchemas[type];\n if (!schema) {\n throw new Error(`Unknown packet kind: ${ type }`);\n }\n\n const dataBuffer = buffer.subarray(offset);\n const data = schema.toObject(dataBuffer) as PacketPayloadMapType[T];\n\n return { ...header, ...data };\n}\n\n/**\n * Encodes an {@link Error} instance into a binary buffer following the packet schema.\n *\n * @param error - The error object to be serialized and encoded.\n * @param suiteId - Identifier of the suite where the error occurred.\n * @param runnerId - Identifier of the runner reporting the error.\n *\n * @returns A {@link Buffer} containing the encoded error packet, ready for transmission.\n *\n * @remarks\n * The function creates two binary sections:\n * - A **header**, describing the packet kind (`Error`), suite ID, runner ID, and timestamp.\n * - A **data buffer**, holding the serialized error details in JSON format.\n *\n * These two sections are concatenated into a single buffer.\n *\n * @example\n * ```ts\n * try {\n * throw new Error(\"Test failed\");\n * } catch (err) {\n * const buffer = encodeErrorSchema(err, \"suite-123\", \"runner-456\");\n * socket.send(buffer); // transmit over a transport channel\n * }\n * ```\n *\n * @see serializeError\n * @see PacketKind.Error\n *\n * @since 1.0.0\n */\n\nexport function encodeErrorSchema(error: Error, suiteId: string, runnerId: string): Buffer {\n const header = headerSchema.toBuffer({\n kind: PacketKind.Error,\n suiteId: suiteId ?? '',\n runnerId: runnerId ?? '',\n timestamp: (new Date()).toISOString()\n });\n\n const dataBuffer = errorSchema.toBuffer({\n error: JSON.stringify(serializeError(error))\n });\n\n return Buffer.concat([ header, dataBuffer ]);\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketLogInterface, PacketStatusInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { PacketErrorInterface, PacketEventsInterface } from '@packets/interfaces/packet-schema.interface';\nimport type { PacketHeaderInterface, PacketInvocationInterface } from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Imports\n */\n\nimport { Struct } from '@remotex-labs/xstruct';\n\n/**\n * Schema for serializing and deserializing {@link PacketInvocationInterface} data.\n *\n * @remarks\n * Represents the location in source code where a test, describe, or log originates.\n *\n * @since 1.0.0\n */\n\nexport const invocationSchema = new Struct<PacketInvocationInterface>({\n line: 'UInt32LE',\n column: 'UInt32LE',\n source: 'string'\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketHeaderInterface} data.\n *\n * @remarks\n * Contains metadata for each packet, including kind, suite and runner identifiers, and timestamp.\n *\n * @since 1.0.0\n */\n\nexport const headerSchema = new Struct<PacketHeaderInterface>({\n kind: 'UInt8:4',\n suiteId: { type: 'string', size: 14 },\n runnerId: { type: 'string', size: 14 },\n timestamp: 'string'\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketLogInterface} data.\n *\n * @remarks\n * Used for console-like logs emitted by tests or describes, including message, level, ancestry, and invocation.\n *\n * @since 1.0.0\n */\n\nexport const logSchema = new Struct<PacketLogInterface>({\n level: 'UInt8',\n message: { type: 'string', lengthType: 'UInt32LE' },\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n invocation: invocationSchema\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketErrorInterface} data.\n *\n * @remarks\n * Represents suite-level fatal errors that are not tied to specific tests or describes.\n *\n * @since 1.0.0\n */\n\nexport const errorSchema = new Struct<PacketErrorInterface>({\n error: { type: 'string', lengthType: 'UInt32LE' }\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketStatusInterface} data.\n *\n * @remarks\n * Represents status updates for individual tests or describe blocks,\n * including whether it is TODO, skipped, and its ancestry and description.\n *\n * @since 1.0.0\n */\n\nexport const statusSchema = new Struct<PacketStatusInterface>({\n type: 'UInt8:5',\n todo: 'UInt8:1',\n skipped: 'UInt8:1',\n duration: 'UInt32LE',\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n description: { type: 'string', lengthType: 'UInt32LE' }\n});\n\n/**\n * Schema for serializing and deserializing {@link PacketEventsInterface} data.\n *\n * @remarks\n * Represents events emitted during the test or describe execution,\n * including pass/fail status, duration, error messages, ancestry, and invocation.\n *\n * @since 1.0.0\n */\n\nexport const eventsSchema = new Struct<PacketEventsInterface>({\n type: 'UInt8:5',\n passed: 'UInt8:1',\n duration: 'UInt32LE',\n ancestry: { type: 'string', lengthType: 'UInt32LE' },\n description: { type: 'string', lengthType: 'UInt32LE' },\n errors: { type: 'string', lengthType: 'UInt32LE' }\n});\n", "/**\n * Import will remove at compile time\n */\n\nimport type { Struct } from '@remotex-labs/xstruct';\n\n/**\n * Imports\n */\n\nimport { errorSchema, eventsSchema, logSchema, statusSchema } from '@packets/schema/packet.schema';\n\n/**\n * Defines the different kinds of packets that can be transmitted or received.\n *\n * @remarks\n * Each packet kind corresponds to a specific type of event or message in the test framework:\n * - `Log`: Console or logging messages\n * - `Error`: Suite-level fatal errors\n * - `Status`: Test or describe start events, including `skipped` and `todo` flags\n * - `Events`: Test or describe end events, only for completed tests/describes (no skipped or TODO)\n *\n * @since 1.0.0\n */\n\nexport const enum PacketKind {\n /**\n * Represents a log message packet, e.g., `console.log`, `console.error`.\n * @since 1.0.0\n */\n\n Log = 1,\n\n /**\n * Represents a fatal suite-level error.\n * Not associated with any test, describe, or hook.\n * @since 1.0.0\n */\n\n Error = 2,\n\n /**\n * Represents a status packet for test or describe start events.\n *\n * @remarks\n * Includes flags for:\n * - `skipped`: Whether the test or describe was skipped\n * - `todo`: Whether the test is marked as TODO\n *\n * @since 1.0.0\n */\n\n Status = 3,\n\n /**\n * Represents an event packet for test or describe end events.\n *\n * @remarks\n * Only includes completed tests/describes; skipped or TODO tests are not included.\n * Contains information such as `passed` and `duration`.\n *\n * @since 1.0.0\n */\n\n Events = 4\n}\n\n/**\n * Maps each {@link PacketKind} to its corresponding {@link Struct} schema for serialization/deserialization.\n *\n * @remarks\n * This object allows encoding and decoding packets of different kinds using\n * their respective `xStruct` schemas. Use `PacketSchemas[PacketKind.Log]` to\n * get the schema for log packets, etc.\n *\n * @see PacketKind\n * @see Struct\n *\n * @since 1.0.0\n */\n\nexport const PacketSchemas: Record<PacketKind, Struct> = {\n [PacketKind.Log]: logSchema,\n [PacketKind.Error]: errorSchema,\n [PacketKind.Status]: statusSchema,\n [PacketKind.Events]: eventsSchema\n} as const;\n", "/**\n * Defines the log verbosity levels for reporters and test execution.\n *\n * @remarks\n * Each level represents the minimum severity of messages that should be\n * captured or displayed. Higher levels include all messages from lower levels.\n *\n * @example\n * ```ts\n * if (log.level >= LogLevel.Warn) {\n * console.warn(log.message);\n * }\n * ```\n *\n * @since 1.0.0\n */\n\nexport enum LogLevel {\n Silent = 0,\n Error = 1,\n Warn = 2,\n Info = 3,\n Debug = 4\n}\n\n/**\n * Defines the types of messages emitted during test execution.\n *\n * @remarks\n * These message types are used internally by reporters, runners,\n * and event emitters to categorize test events. Each type corresponds\n * to a specific stage or element of the test lifecycle.\n *\n * @example\n * ```ts\n * if (message.type === MessageType.Test) {\n * console.log('Test event received');\n * }\n * ```\n *\n * @since 1.0.0\n */\n\nexport const enum MessageType {\n Test = 1,\n Describe = 2,\n EndSuite = 3,\n StartSuite = 4\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { HookModel } from './hook.model';\nimport type { TestModel } from '@shared/models/test.model';\nimport type { ContextType } from '@remotex-labs/xjet-expect';\nimport type { ContextInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeHooksInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { MessageType } from '@messages/constants/report.constant';\nimport { emitEvent, emitStatus } from '@shared/services/emit.service';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\n\n/**\n * Represents a test suite container that manages test execution flow and hierarchy\n *\n * @template T - Context type for test execution\n * @param description - The description of the test suite\n * @param describeFlags - Configuration options for the test suite\n * @returns A new DescribeModel instance that can contain tests and nested suites\n *\n * @remarks\n * The DescribeModel manages the execution lifecycle of tests, including\n * - Maintaining parent-child relationships between test suites\n * - Executing hooks in the correct order (beforeAll, beforeEach, afterEach, afterAll)\n * - Tracking test execution status and reporting results\n * - Supporting test filtering with skip/only options\n *\n * @example\n * ```ts\n * const rootSuite = new DescribeModel('Root suite');\n * const testCase = new TestModel('should work', () => {\n * expect(true).toBe(true);\n * });\n * rootSuite.addTest(testCase);\n * await rootSuite.run({});\n * ```\n *\n * @see TestModel\n * @see HookModel\n * @see DescribeHooksInterface\n *\n * @since 1.0.0\n */\n\nexport class DescribeModel {\n /**\n * Array containing the hierarchical path of parent describe blocks for this test suite\n *\n * @since 1.0.0\n */\n\n readonly ancestry: string[] = [];\n\n /**\n * Collection of test cases directly contained within this test suite\n *\n * @internal\n * @since 1.0.0\n */\n\n readonly testsStack: TestModel[] = [];\n\n /**\n * Collection of nested test suites within this suite\n *\n * @internal\n * @since 1.0.0\n */\n\n readonly describesStack: DescribeModel[] = [];\n\n /**\n * Timestamp when the test suite execution started\n *\n * @default 0\n * @internal\n * @since 1.0.0\n */\n\n private startTime = 0;\n\n /**\n * Collection of lifecycle hooks for this test suite\n *\n * @internal\n * @since 1.0.0\n */\n\n private readonly hooks: DescribeHooksInterface = {\n afterAll: [],\n afterEach: [],\n beforeAll: [],\n beforeEach: []\n };\n\n /**\n * Creates a new test suite with the specified description and options\n *\n * @param description - Human-readable description of the test suite\n * @param describeOptions - Configuration options to control test suite execution\n *\n * @since 1.0.0\n */\n\n constructor(\n readonly description: string = '',\n private readonly describeOptions: DescribeOptionsInterface = { skip: false, only: false }\n ) {\n }\n\n /**\n * Retrieves the execution configuration options for this test suite\n *\n * @returns Test suite configuration options\n *\n * @since 1.0.0\n */\n\n get options(): DescribeOptionsInterface {\n return this.describeOptions;\n }\n\n /**\n * Gets all tests in this suite, including tests from nested suites\n *\n * @returns Flattened array of all tests in this suite and its children\n *\n * @remarks\n * Recursively collects and flattens all test cases from this suite and any nested suites\n *\n * @since 1.0.0\n */\n\n get tests(): TestModel[] {\n // Use flatMap for cleaner code and better performance\n return [\n ...this.testsStack,\n ...this.describesStack.flatMap(child => child.tests)\n ];\n }\n\n /**\n * Registers a hook function to be executed at a specific point in the test lifecycle\n *\n * @param type - The lifecycle point at which to execute the hook\n * @param hook - The hook function model to register\n *\n * @throws Error - If an invalid hook type is provided\n *\n * @since 1.0.0\n */\n\n addHook(type: HookType, hook: HookModel): void {\n const hookArray = this.hooks[type];\n if (!hookArray) {\n throw new Error(`Invalid hook type: ${ type }`);\n }\n\n hookArray.push(hook);\n }\n\n /**\n * Adds a test case to this test suite\n *\n * @param test - The test model to add to the suite\n *\n * @remarks\n * When adding a test, this method automatically:\n * - Updates the test's ancestry to include this suite\n * - Propagates execution options (skip/only) from the suite to the test\n *\n * @since 1.0.0\n */\n\n addTest(test: TestModel): void {\n if (!test) return;\n\n test.setAncestry(this.ancestry);\n if (this.description) test.setAncestry([ this.description ]);\n test.applyExecutionFlags(this.options.skip, this.options.only);\n this.testsStack.push(test);\n }\n\n /**\n * Adds a nested test describe to this test describe\n *\n * @param describe - The child test describe to add\n *\n * @remarks\n * When adding nested describe, this method automatically:\n * - Sets up the parent-child relationship\n * - Propagates execution options and ancestry information from parent to child\n *\n * @since 1.0.0\n */\n\n addDescribe(describe: DescribeModel): void {\n if (!describe) return;\n\n describe.inheritFromParentDescribe(this);\n this.describesStack.push(describe);\n }\n\n /**\n * Executes the test suite and all contained tests\n *\n * @param context - The test execution context containing shared state\n * @returns Promise that resolves when all tests in the suite complete\n *\n * @remarks\n * Execution follows this order:\n * 1. Check if the suite is marked as skipped\n * 2. Execute all beforeAll hooks\n * 3. Run all tests in this suite\n * 4. Run all nested test suites\n * 5. Execute all afterAll hooks\n * If any step fails, the entire suite is marked as failed\n *\n * @example\n * ```ts\n * const suite = new DescribeModel('My test suite');\n * const context = createTestContext();\n * await suite.run(context);\n * ```\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<ContextInterface>): Promise<void> {\n this.startTime = Date.now();\n this.notifyDescribeStatus(this.options.skip);\n const afterAllErrorsEmpty = !context.afterAllErrors?.length;\n const beforeAllErrorsEmpty = !context.beforeAllErrors?.length;\n\n try {\n if (!context.beforeAllErrors?.length)\n await this.executeHooks(HookType.BEFORE_ALL, context);\n\n for (const test of this.shuffleTests(this.testsStack)) {\n if(context.hasError) return;\n await test.run(context, this.executeHooks.bind(this));\n }\n\n for (const describe of this.describesStack) {\n if(context.hasError) return;\n await describe.run(context);\n }\n\n await this.executeHooks(HookType.AFTER_ALL, context);\n\n if (context.afterAllErrors?.length) this.notifyDescribeFailure(context.afterAllErrors);\n else this.notifyDescribeAction();\n } catch (error) {\n this.notifyDescribeFailure([ error, ...context.afterAllErrors ]);\n if(globalThis.__XJET?.runtime.bail) {\n context.hasError = true;\n }\n } finally {\n if (afterAllErrorsEmpty) context.afterAllErrors = [];\n if (beforeAllErrorsEmpty) context.beforeAllErrors = [];\n }\n }\n\n /**\n * Inherits properties from a parent test suite\n *\n * @param parent - The parent test describe to inherit from\n *\n * @remarks\n * This method performs the following inheritance operations:\n * - Adds parent's ancestry chain to this suite's ancestry\n * - Propagates the 'skip' flag (if parent is skipped, child is skipped)\n * - Propagates the 'only' flag if the parent has it set\n *\n * @since 1.0.0\n */\n\n inheritFromParentDescribe(parent: DescribeModel): void {\n this.ancestry.push(...parent.ancestry);\n this.hooks.beforeEach = [ ...parent.hooks.beforeEach, ...this.hooks.beforeEach ];\n this.hooks.afterEach = [ ...parent.hooks.afterEach, ...this.hooks.afterEach ];\n\n if (parent.description)\n this.ancestry.push(parent.description);\n\n if (parent.options.skip) {\n this.describeOptions.skip = true;\n }\n\n if (parent.options.only) {\n this.describeOptions.only = true;\n }\n }\n\n /**\n * Executes all hooks of the specified type in sequence\n *\n * @param type - The lifecycle hook type to execute\n * @param context - The test execution context\n *\n * @throws Error - When a beforeEach or afterEach hook fails\n *\n * @remarks\n * Errors in beforeAll hooks are collected but don't immediately abort execution.\n * Errors in afterAll hooks are collected for reporting.\n * Errors in beforeEach/afterEach hooks cause immediate test failure.\n *\n * @internal\n * @since 1.0.0\n */\n\n private async executeHooks(type: HookType, context: ContextType<ContextInterface>): Promise<void> {\n if (this.options.skip) return;\n context.beforeAllErrors = context.beforeAllErrors || [];\n context.afterAllErrors = context.afterAllErrors || [];\n\n for (const hook of this.hooks[type]) {\n try {\n await hook.run(context);\n } catch (error) {\n await this.handleHookError(type, error, context);\n }\n }\n }\n\n /**\n * Handles errors that occur during hook execution\n *\n * @param type - The type of hook where the error occurred\n * @param error - The error that was thrown\n * @param context - The test execution context\n *\n * @throws Error - When the error occurs in a beforeEach or afterEach hook\n *\n * @remarks\n * Error handling differs by hook type:\n * - beforeAll: Error is collected but execution continues\n * - afterAll: Error is collected for reporting\n * - beforeEach/afterEach: Error is immediately thrown to fail the test\n *\n * @internal\n *\n * @since 1.0.0\n */\n\n private async handleHookError(type: HookType, error: unknown, context: ContextType<ContextInterface>): Promise<void> {\n if (type === HookType.BEFORE_ALL) {\n context.beforeAllErrors.push(error);\n } else if (type === HookType.AFTER_ALL) {\n context.afterAllErrors.push(error);\n } else {\n throw error;\n }\n }\n\n /**\n * Calculates the execution duration of the test suite in milliseconds\n *\n * @returns Duration in milliseconds since the test started, or 0 if not started\n *\n * @remarks\n * Returns the elapsed time between when the suite started execution and the current time\n * If the suite hasn't started (startTime is 0), returns 0 instead\n *\n * @internal\n * @since 1.0.0\n */\n\n private getExecutionDuration(): number {\n if (this.startTime === 0)\n return 0;\n\n return Date.now() - this.startTime;\n }\n\n private notifyDescribeStatus(skip: boolean = false): void {\n emitStatus(MessageType.Describe, {\n skipped: skip,\n ancestry: this.ancestry,\n description: this.description\n });\n }\n\n private notifyDescribeAction(errors: Array<unknown> = []): void {\n emitEvent(MessageType.Describe, {\n errors: <Array<Error>> errors,\n ancestry: this.ancestry,\n description: this.description,\n duration: this.getExecutionDuration()\n });\n }\n\n /**\n * Reports test suite failure with associated errors\n *\n * @param errors - Collection of errors that caused the test suite to fail\n *\n * @remarks\n * Skips reporting if no errors are provided\n * Uses notifyDescribeAction to emit a failure event with the error details\n *\n * @internal\n * @since 1.0.0\n */\n\n private notifyDescribeFailure(errors: Array<unknown>): void {\n if (!errors?.length) return;\n\n this.notifyDescribeAction(errors);\n }\n\n /**\n * Randomizes the order of tests in an array using the Fisher-Yates shuffle algorithm\n *\n * @param testsToShuffle - Array of test models to be randomly reordered\n * @returns The same array with elements potentially reordered in a random sequence\n *\n * @remarks\n * The shuffling only occurs if the global randomization flag is enabled\n * (accessed via globalThis.__XJET?.runtime.randomize) and the array has more\n * than one element. The algorithm used is Fisher-Yates shuffle, which ensures\n * each permutation has equal probability.\n *\n * @example\n * ```ts\n * const tests = [new TestModel('test1'), new TestModel('test2')];\n * const randomizedTests = this.shuffleTests(tests);\n * // The order of tests may be different from the original if randomization is enabled\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n private shuffleTests(testsToShuffle: Array<TestModel>): Array<TestModel> {\n const randomize = globalThis.__XJET?.runtime.randomize ?? false;\n if (!randomize || testsToShuffle.length <= 1) return testsToShuffle;\n const length = testsToShuffle.length;\n\n // Start from the last element and swap with a random element\n // before the current position (including itself)\n for (let i = length - 1; i > 0; i--) {\n // Generate a random index from 0 to i (inclusive)\n const j = Math.floor(Math.random() * (i + 1));\n\n // Swap elements at indices i and j\n // Use destructuring assignment for a clean swap without a temp variable\n [ testsToShuffle[i], testsToShuffle[j] ] = [ testsToShuffle[j], testsToShuffle[i] ];\n }\n\n return testsToShuffle;\n }\n}\n", "/**\n * A base error class that extends the standard Error class with enhanced JSON serialization and location tracking\n *\n * @param message - The error message describing what went wrong\n * @param location - The precise source code location where the error occurred\n * @returns The constructed ExecutionError instance\n *\n * @remarks\n * Serves as a foundation for custom error types in the application.\n * It enhances the native Error object by adding JSON serialization capabilities\n * and source code location information, allowing for better error reporting,\n * debugging, and troubleshooting. The location tracking feature helps pinpoint\n * exactly where in the codebase an error originated.\n *\n * @example\n * ```ts\n * // Creating a basic execution error with location information\n * const error = new ExecutionError(\n * 'Failed to process data',\n * { line: 42, column: 10 }\n * );\n *\n * // The error can be thrown or used in promise rejection\n * throw error;\n * ```\n *\n * @see InvocationLocationType\n *\n * @since 1.0.0\n */\n\nexport class ExecutionError extends Error {\n\n /**\n * Creates a new ExecutionError instance with the specified error message and source code location\n *\n * @param message - The error message describing what went wrong\n *\n * @remarks\n * This constructor initializes both the standard Error message property and the location\n * information that helps pinpoint exactly where in the codebase the error originated. The\n * location parameter follows the InvocationLocationType structure, typically containing\n * line and column information.\n *\n * @example\n * ```ts\n * const error = new ExecutionError(\n * 'Failed to process input data',\n * { line: 42, column: 8 }\n * );\n * ```\n *\n * @since 1.0.0\n */\n\n constructor(message: string) {\n super(message);\n\n // Assign the name of the error\n this.name = 'xJetExecutionError';\n }\n\n /**\n * Converts the error instance to a plain JavaScript object for JSON serialization.\n *\n * @returns A plain object containing all properties of the error.\n *\n * @remarks\n * This method enhances error serialization by ensuring all properties from the error\n * instance are properly included in the resulting JSON representation. The standard\n * `JSON.stringify()` method doesn't properly serialize Error objects by default, as\n * their properties are typically not enumerable.\n *\n * @example\n * ```ts\n * const error = new ExecutionError('Something went wrong');\n * error.code = 'ERR_INVALID_INPUT';\n *\n * // Convert to JSON\n * const serialized = JSON.stringify(error);\n * // Result includes all properties: message, name, stack, code, etc.\n * ```\n *\n * @since 1.0.0\n */\n\n toJSON(): Record<string, unknown> {\n const json: Record<string, unknown> = {};\n\n for (const key of Object.keys(this)) {\n const value = this[key as keyof this];\n if(value) json[key] = value;\n }\n\n json.name = this.name;\n json.stack = this.stack;\n json.message = this.message;\n\n return json;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestModel } from '@shared/models/test.model';\nimport type { ContextType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { ContextInterface, DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { Injectable } from '@symlinks/symlinks.module';\nimport { emitStatus } from '@shared/services/emit.service';\nimport { encodeErrorSchema } from '@packets/packets.module';\nimport { DescribeModel } from '@shared/models/describe.model';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { MessageType } from '@messages/constants/report.constant';\n\n/**\n * Manages the state of test suites within the testing framework, tracking the hierarchy of describe blocks and test cases.\n * Implemented as a singleton to ensure a single source of truth for the test suite structure.\n *\n * @template TestModel - The model type representing individual test cases\n * @template FunctionType - The function type for describe block implementations\n * @template DescribeModel - The model type representing test suite describe blocks\n * @template DescribeOptionsInterface - Configuration options for describe blocks\n *\n * @throws Error - If you attempt to instantiate this class directly instead of using getInstance()\n *\n * @remarks\n * The singleton pattern ensures that all test registration operations work with the same\n * state instance, properly maintaining the hierarchical structure of tests.\n * Use the static getInstance() method to access the singleton instance.\n *\n * @example\n * ```ts\n * // Get the singleton instance\n * const suiteState = SuiteState.getInstance();\n *\n * // Add a describe block\n * suiteState.addDescribe('My test suite', () => {\n * // Test suite implementation\n * }, { only: true });\n *\n * // Add a test case to the current describe block\n * suiteState.addTest(new TestModel('should work', () => {}, { skip: false }));\n * ```\n *\n * @see TestModel\n * @see DescribeModel\n *\n * @since 1.0.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class SuiteState {\n /**\n * Tracks whether any test or describe block has the 'only' flag set\n *\n * @since 1.0.0\n */\n\n private onlyMode = false;\n\n /**\n * Reference to the currently active describe block in the test hierarchy\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n private currentDescribe: DescribeModel;\n\n /**\n * Reference to the test currently being defined or executed\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n private currentTest?: TestModel;\n\n /**\n * Suite has at least one test\n * @since 1.0.0\n */\n\n private hasTests = false;\n\n /**\n * The top-level describe block that contains all tests and nested describe blocks\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n private readonly rootDescribe: DescribeModel;\n\n /**\n * Array of regular expressions used for filtering test paths\n *\n * @remarks\n * This array stores regular expressions created from filter strings specified in runtime configuration.\n * Used to determine which tests should be executed when filtering is enabled.\n *\n * @see SuiteState.matchesFilter - Method that uses these regex patterns for test filtering\n * @since 1.0.0\n */\n\n private readonly filterRegexChain: Array<RegExp> = [];\n\n /**\n * Creates a new instance of the class with a root describe block\n *\n * @internal\n * @since 1.0.0\n */\n\n constructor() {\n this.rootDescribe = new DescribeModel();\n this.currentDescribe = this.rootDescribe;\n\n if (Array.isArray(__XJET?.runtime.filter) && __XJET.runtime.filter.length > 0) {\n this.onlyMode = true;\n this.filterRegexChain = __XJET.runtime.filter.map(\n (part: string) => new RegExp(`^${ part }$`)\n );\n }\n }\n\n /**\n * Checks if a test path matches the provided regular expression filter patterns\n *\n * This method compares a test's full path (including ancestry and description) against one or more\n * regular expression patterns to determine if the test should be included in execution.\n *\n * @param path - Array of path segments representing test ancestry and description\n * @param filter - Array of RegExp objects to test against the path\n * @returns Boolean indicating whether the path matches the filter patterns\n *\n * @throws Error - When invalid regular expressions are provided\n *\n * @remarks\n * The method aligns the filter from the end of the path, allowing partial matching of nested test structures.\n * This is particularly useful for selecting specific test cases within a larger test hierarchy.\n *\n * @example\n * ```ts\n * // Match tests with description containing \"login\"\n * const matches = SuiteState.matchesFilter(\n * ['Auth', 'User', 'should handle login correctly'],\n * [/login/i]\n * );\n * // Returns: true\n *\n * // Match specific test path structure\n * const matches = SuiteState.matchesFilter(\n * ['API', 'GET', 'should return 200 status'],\n * [/API/, /GET/, /status/]\n * );\n * // Returns: true\n * ```\n *\n * @see filterChain - String-based alternative for exact matching\n * @see addTest - Method that uses matchesFilter to determine which tests to run\n *\n * @since 1.0.0\n */\n\n static matchesFilter(path: string[], filter: RegExp[]): boolean {\n if (filter.length > path.length) return false;\n\n // Align from the end of the path\n const offset = path.length - filter.length;\n\n return filter.every((re, i) => re.test(path[offset + i]));\n }\n\n /**\n * Indicates whether the test suite is running in \"only\" mode\n *\n * @returns True if only specifically marked tests should run\n *\n * @since 1.0.0\n */\n\n get isOnlyMode(): boolean {\n return this.onlyMode;\n }\n\n /**\n * Gets the root describe block of the test suite\n *\n * @returns The top-level describe block\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n get root(): DescribeModel {\n return this.rootDescribe;\n }\n\n /**\n * Gets the current describe block being defined\n *\n * @returns The active describe block\n *\n * @see DescribeModel\n * @since 1.0.0\n */\n\n get describe(): DescribeModel {\n return this.currentDescribe;\n }\n\n /**\n * Gets the test currently being defined or executed\n *\n * @returns The current test or null if no test is active\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n get test(): TestModel | undefined {\n return this.currentTest;\n }\n\n /**\n * Sets the current test being defined or executed\n *\n * @param test - The test to set as current\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n set test(test: TestModel | undefined) {\n this.currentTest = test;\n }\n\n /**\n * Executes the entire test suite from the root describe block\n *\n * @param context - The execution context containing runtime information\n *\n * @throws Error - When test execution fails, the error is encoded and dispatched\n *\n * @remarks\n * This method initiates the test execution flow by calling run() on the root describe block\n * and emits an END status notification when all tests complete successfully. If an error\n * occurs during execution, it's captured, encoded, and dispatched through the error schema.\n *\n * @example\n * ```ts\n * const suiteState = SuiteState.getInstance();\n * await suiteState.run({\n * timeout: 5000,\n * currentPath: '/tests',\n * skipAfterFailure: true\n * });\n * ```\n *\n * @see emitStatus\n * @see DescribeModel\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<ContextInterface>): Promise<void> {\n try {\n const time = Date.now();\n emitStatus(MessageType.StartSuite);\n if (!this.hasTests)\n throw new ExecutionError('Your test suite must contain at least one test');\n\n await this.root.run(context);\n emitStatus(MessageType.EndSuite, { duration: Date.now() - time });\n } catch (e) {\n dispatch(\n encodeErrorSchema(<Error>e, __XJET.runtime.suiteId, __XJET.runtime.runnerId)\n );\n } finally {\n xJet.restoreAllMocks();\n }\n }\n\n /**\n * Adds a new describe block to the test suite hierarchy\n *\n * @param description - The textual description of the describe block\n * @param describeFn - The function containing the tests and nested describes\n * @param flags - Configuration options for the describe block\n * @param describeArgs - Arguments to pass to the describe function\n *\n * @throws Error - If the describe function throws any exceptions\n *\n * @remarks\n * This method temporarily changes the current describe context while executing\n * the describeFn, then restores it afterward, ensuring proper nesting of test blocks.\n * If the 'only' flag is set, it enables only-mode for the entire test suite.\n *\n * @example\n * ```ts\n * suiteState.addDescribe(\n * 'my test group',\n * () => {\n * // test definitions here\n * },\n * { only: true }\n * );\n * ```\n *\n * @see FunctionType\n * @see DescribeModel\n * @see DescribeOptionsInterface\n *\n * @since 1.0.0\n */\n\n addDescribe(description: string, describeFn: FunctionType, flags: DescribeOptionsInterface = {}, describeArgs: Array<unknown> = []): void {\n const options = { skip: false, only: false, ...flags };\n if (options.only) {\n this.onlyMode = true;\n }\n\n if (this.filterRegexChain.length > 0) {\n const fullPath = [\n ...this.currentDescribe.ancestry,\n this.currentDescribe.description,\n description\n ];\n\n if (SuiteState.matchesFilter(fullPath, this.filterRegexChain)) {\n options.only = true;\n }\n }\n\n const newDescribe = new DescribeModel(description, options);\n this.currentDescribe.addDescribe(newDescribe);\n const previousDescribe = this.currentDescribe;\n this.currentDescribe = newDescribe;\n\n try {\n describeFn.apply({}, describeArgs);\n } finally {\n this.currentDescribe = previousDescribe;\n }\n }\n\n /**\n * Adds a test to the current describe block\n *\n * @param test - The test model to add\n *\n * @remarks\n * If the test has the 'only' option set, it enables only-mode for the entire test suite.\n *\n * @see TestModel\n * @since 1.0.0\n */\n\n addTest(test: TestModel): void {\n // Mark the suite as having at least one test\n this.hasTests = true;\n\n if (test.options.only) this.onlyMode = true;\n this.currentDescribe.addTest(test);\n\n if (this.filterRegexChain.length > 0) {\n const fullPath = [ ...test.ancestry, test.description ];\n\n if (SuiteState.matchesFilter(fullPath, this.filterRegexChain)) {\n test.options.only = true;\n }\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestModel } from '@shared/models/test.model';\nimport type { DescribeModel } from '@shared/models/describe.model';\n\n/**\n * Imports\n */\n\nimport { serialize } from '@remotex-labs/xjet-expect';\nimport { encodePacket } from '@packets/packets.module';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { LogLevel } from '@messages/constants/report.constant';\nimport { getInvocationLocation } from '@components/location.component';\nimport { PacketKind } from '@packets/constants/packet-schema.constants';\n\n/**\n * Creates a logging function that formats and dispatches log messages with timestamps\n *\n * @template T - Console method type that determines the log level\n * @param type - The type of console method (log, info, warn, error) to create a handler for\n * @returns A function that accepts any number of arguments, formats them, and dispatches a log event\n *\n * @throws TypeError - When invalid arguments are provided to the returned function\n *\n * @remarks\n * This function acts as a factory for creating specialized logging handlers. Each handler:\n * - Timestamps the log entry with ISO format\n * - Formats all arguments into string representations\n * - Dispatches the log event with the appropriate log level\n * - Maintains a consistent format for all log messages\n *\n * @example\n * ```ts\n * const logInfo = createLogHandler('info');\n * logInfo('User', user.id, 'logged in successfully');\n * // Dispatches a log event with level: 'INFO', formatted arguments, and timestamp\n * ```\n *\n * @see formatValue\n * @see dispatch\n * @see SchemaType\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport function createLogHandler(type: keyof typeof LogLevel) {\n return function (...args: unknown[]): void {\n let parent: TestModel | DescribeModel | undefined = inject(SuiteState).test;\n if (!parent) {\n parent = inject(SuiteState).describe;\n }\n\n const context = [ ...parent?.ancestry ?? [], parent?.description ].join(',');\n\n // Format arguments for the description\n const formattedArgs = args.map((data: unknown) => serialize(data).join('\\n')).join(' ');\n const location = getInvocationLocation();\n\n // Dispatch log event\n dispatch(encodePacket(PacketKind.Log, {\n level: LogLevel[type],\n message: formattedArgs,\n ancestry: context ?? '',\n invocation: location\n }));\n };\n}\n\n/**\n * Standard log level function for general purpose logging\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const log = createLogHandler('Info');\n\n/**\n * Informational log function for highlighting noteworthy application events\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const info = createLogHandler('Info');\n\n/**\n * Warning log function for potential issues that aren't errors\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const warn = createLogHandler('Warn');\n\n/**\n * Error log function for reporting application errors and exceptions\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const error = createLogHandler('Error');\n\n/**\n * Debug log function for detailed diagnostic information\n *\n * @see createLogHandler\n * @see LogLevel\n *\n * @since 1.0.0\n */\n\nexport const debug = createLogHandler('Debug');\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PacketInvocationInterface } from '@packets/interfaces/packet-schema.interface';\n\n/**\n * Imports\n */\n\nimport { parseErrorStack } from '@remotex-labs/xmap/parser.component';\n\n/**\n * Retrieves the location in the source code where this function was invoked.\n *\n * @param position - The stack frame index to inspect (default is 3). This allows skipping\n * internal frames to reach the actual caller.\n * @returns A {@link PacketInvocationInterface} containing `line`, `column`, and `source` file\n * of the invocation, or `undefined` if the location could not be determined.\n *\n * @remarks\n * This function generates a new `Error` to capture the stack trace, parses it using\n * {@link parseErrorStack}, and returns the requested frame as a structured object.\n * It is useful for logging or reporting the exact location of a call within test suites\n * or framework code.\n *\n * @see parseErrorStack\n * @see PacketInvocationInterface\n *\n * @since 1.0.0\n */\n\nexport function getInvocationLocation(position: number = 2): PacketInvocationInterface | undefined {\n const errorObject = parseErrorStack(new Error());\n const stack = errorObject.stack[position];\n\n if (stack?.line && stack?.column && stack?.fileName) {\n return {\n line: stack.line!,\n column: stack.column!,\n source: stack.fileName!\n };\n }\n\n return undefined;\n}\n\n/**\n * Returns a native-style stack trace string,\n * trimmed to start at the specified frame index.\n *\n * @remarks\n * The first line (error name/message) is preserved,\n * while the following lines are sliced starting from `position`.\n *\n * @param position - Index of the first stack frame to include.\n * Defaults to `2` to skip this helper and its caller.\n *\n * @returns A string identical in format to `Error.stack`,\n * or an empty string if the stack is unavailable.\n *\n * @example\n * ```ts\n * console.log(getTrimmedStackString(2));\n * ```\n *\n * @since 3.1.0\n */\n\nexport function getTrimmedStackString(position: number = 2): string {\n const err = new Error();\n if (!err.stack) return '';\n\n const lines = err.stack.split('\\n');\n const frames = lines.slice(position + 1);\n\n return frames.join('\\n');\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { DeepSearchInterface } from '@shared/components/interfaces/object.interface';\n\n/**\n * Recursively searches for a specific element within an object or its nested properties.\n *\n * @param target - The object to search within.\n * @param element - The value to find within the target object or its nested properties.\n * @param key - Optional specific key to search for within the target object.\n * @param maxDepth - Maximum recursion depth to prevent infinite loops, defaults to 3.\n * @returns A {@link DeepSearchInterface} object containing parent and key if found, or null if not found.\n *\n * @remarks\n * This utility performs a depth-first search through an object's properties to locate a specific value\n * or a property with a specific key. It maintains a set of visited objects to prevent circular reference issues.\n *\n * The search process:\n * - Tracks visited objects to avoid circular references\n * - Searches by exact reference equality for the element\n * - Handles errors during property access\n * - Limits search depth to prevent stack overflow\n * - Can find elements by exact key name (when the `key` parameter is provided)\n *\n * @example\n * ```ts\n * const obj = {\n * a: 1,\n * b: {\n * c: 'test',\n * d: [1, 2, { e: 'target' }]\n * }\n * };\n *\n * // Find by value\n * const result = deepSearchObject(obj, 'target');\n * // result: { parent: { e: 'target' }, key: 'e' }\n *\n * // Find by key name\n * const byKey = deepSearchObject(obj, null, 'c');\n * // byKey: { parent: { c: 'test', d: [...] }, key: 'c' }\n * ```\n *\n * @see DeepSearchInterface\n * @since 1.0.0\n */\n\nexport function deepSearchObject(\n target: Record<string | symbol, unknown>, element: unknown, key?: string | symbol, maxDepth: number = 3\n): DeepSearchInterface | null {\n const visited = new WeakSet<object>();\n\n function search(current: Record<string | symbol, unknown>, depth: number): DeepSearchInterface | null {\n if (depth > maxDepth || current == null) return null;\n if (typeof current !== 'object' && typeof current !== 'function') return null;\n if (visited.has(current)) return null;\n visited.add(current);\n\n if (element === null && key && key in current)\n return { parent: current, key };\n\n if (key && key in current && Object.is(current[key], element))\n return { parent: current, key };\n\n for (const [ prop, value ] of Object.entries(current)) {\n if (Object.is(value, element)) return { parent: current, key: prop };\n if (value && (typeof value === 'object' || typeof value === 'function')) {\n const found = search(value as Record<string | symbol, unknown>, depth + 1);\n if (found) return found;\n }\n }\n\n return null;\n }\n\n return search(target, 0);\n}\n\n/**\n * Resolves property references that may be affected by ESBuild's `__toESM` transformation.\n *\n * @remarks\n * This function handles a specific issue with ESBuild's module transformation where Node.js\n * built-in modules (like 'fs', 'http', etc.) are wrapped with getter descriptors that aren't\n * configurable. This causes problems when trying to mock or modify these modules in testing.\n *\n * When ESBuild transforms CommonJS modules to ESM, it creates non-configurable getter properties\n * on the module object. This function detects such cases and returns a reference to the original\n * underlying object instead, making the property accessible for mocking or modification.\n *\n * @param parent - The object containing the property to resolve\n * @param key - The property name or symbol to resolve\n * @returns A {@link DeepSearchInterface} pointing to either the original object or the\n * underlying object in case of non-configurable ESBuild transformations\n *\n * @example\n * ```ts\n * // When working with an ESBuild transformed fs module\n * import * as fs from 'fs';\n *\n * // Normal access would use a non-configurable getter\n * // Making it impossible to mock\n * const originalRef = { parent: fs, key: 'readFileSync' };\n *\n * // This function resolves to the underlying object\n * const mockableRef = getOwnProperty(fs, 'readFileSync');\n * // Now we can mock it: mockableRef.parent[mockableRef.key] = mockFn;\n * ```\n *\n * @since 1.2.2\n */\n\nexport function getOwnProperty(parent: Record<string | symbol, unknown>, key: string | symbol): DeepSearchInterface {\n const method = Reflect.get(parent, key);\n const descriptor = Object.getOwnPropertyDescriptor(parent, key);\n\n if (descriptor?.get && !descriptor.configurable) {\n if ('default' in parent && Reflect.get(<object> parent.default, key) === method) {\n return { parent: <Record<string, unknown>> parent.default, key };\n }\n }\n\n return { parent, key };\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ConstructorLikeType, FunctionLikeType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { MockableFunctionInterface, PartialResolvedType } from '@shared/mock/interfaces/fn-mock.interface';\n\n/**\n * Imports\n */\n\nimport { MockState } from '@shared/states/mock.state';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { deepSearchObject, getOwnProperty } from '@shared/components/object.component';\n\n/**\n * Creates a mock for an object property using property descriptors.\n *\n * @template T - The type of the target object containing the property to mock\n *\n * @param target - The object containing the property to mock\n * @param key - The name of the property to mock\n * @returns A {@link MockState} instance that tracks interactions with the property\n *\n * @remarks\n * The `mockDescriptorProperty` function replaces a property on a target object with a getter/setter\n * that intercepts access to that property. This allows for monitoring and controlling property\n * access during tests. The original property can be restored later through the mock's\n * restore capability.\n *\n * Responsibilities:\n * - Intercepting property access via custom property descriptors\n * - Capturing the original property value and descriptor\n * - Creating a {@link MockState} instance to track interactions\n * - Supporting property restoration through the {@link MockState.mockRestore} method\n * - Maintaining references in the global {@link MockState.mocks} registry\n *\n * @example\n * ```ts\n * // Mock a property on an object\n * const obj = { value: 42 };\n * const mockValue = mockDescriptorProperty(obj, 'value');\n * ```\n *\n * @see MockState\n * @since 1.2.0\n */\n\nexport function mockDescriptorProperty<T extends object>(target: T, key: string | number | symbol): MockState {\n const original = Reflect.get(<object> target, key);\n const originalDescriptor = Object.getOwnPropertyDescriptor(target, key) || {};\n const mockInstance = new MockState(() => original, () => {\n Reflect.set(target, key, originalDescriptor.value);\n Object.defineProperty(target, key, originalDescriptor);\n }, `xJet.spyOn(${ String(key) })`);\n\n MockState.mocks.add(new WeakRef(mockInstance));\n Object.defineProperty(target, key, {\n get() {\n return mockInstance.apply(this, []);\n },\n set(value: unknown) {\n mockInstance.mockImplementation(() => value);\n\n return mockInstance.apply(this, [ value ]);\n }\n });\n\n return mockInstance;\n}\n\n/**\n * Creates a mock function interface with the specified implementation and optional restore function.\n *\n * @template ReturnType - The return type of the mocked function.\n * @template Args - The argument type of the mocked function. Defaults to an array of unknown values.\n * @template Context - The context type that the mocked function binds to.\n *\n * @param implementation - An optional implementation of the mocked function.\n * @param restore - An optional restore function used to reset the mock.\n * @returns A mocked function interface with the specified behaviors.\n *\n * @remarks\n * The `fnImplementation` function creates a mock function handler, typically used in testing scenarios.\n * It transforms regular functions into mockable objects that can be monitored and controlled.\n *\n * Responsibilities:\n * - Creating mock functions with custom implementations\n * - Supporting restore functionality for resetting mocks\n * - Providing type-safe mock interfaces via {@link MockableFunctionInterface}\n * - Integrating with the {@link MockState} system\n *\n * @example\n * ```ts\n * // Creating a mock with a custom implementation\n * const mock = xJet.fn((x: number) => x * 2);\n * console.log(mock(5)); // 10\n *\n * // Creating a mock with a restore function\n * const mockWithRestore = xJet.fn(undefined, () => { console.log('Restored!'); });\n * mockWithRestore.restore(); // \"Restored!\"\n * ```\n *\n * @see MockState\n * @see MockableFunctionInterface\n * @see FunctionLikeType\n *\n * @since 1.2.0\n */\n\nexport function fnImplementation<ReturnType, Args extends Array<unknown>, Context>(\n implementation?: FunctionLikeType<ReturnType, Args, Context>,\n restore?: () => FunctionLikeType<ReturnType, Args, Context> | void\n): MockableFunctionInterface<FunctionLikeType<ReturnType, Args, Context>> {\n return <MockableFunctionInterface<FunctionLikeType<ReturnType, Args, Context>>>\n new MockState(implementation, restore, 'xJet.fn()');\n}\n\n/**\n * Creates a mock implementation of the provided class constructor.\n *\n * @param method - The class constructor to mock\n * @param implementation - Optional custom implementation of the mocked constructor\n * @returns The mock state associated with the mocked constructor\n *\n * @remarks\n * This overload of the mockImplementation function is specifically designed for mocking class constructors.\n * It allows for replacing a class implementation during testing while tracking instantiation.\n *\n * The implementation function can return a partial instance of the class, which will be used\n * as the constructed object when the mock is called with 'new'.\n *\n * @example\n * ```ts\n * class User {\n * name: string;\n * age: number;\n * constructor (name: string, age: number) {\n * this.name = name;\n * this.age = age;\n * }\n * }\n *\n * const MockUser = mockImplementation(User, (name, age) => ({ name, age: age + 1 }));\n * const user = new MockUser('Alice', 30); // user.age === 31\n * MockUser.verify.called(); // passes\n * ```\n *\n * @since 1.2.2\n */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mockImplementation<F extends abstract new (...args: any) => any>(\n method: F,\n implementation?: (...args: ConstructorParameters<F>) => PartialResolvedType<InstanceType<F>>\n): MockState<(...args: ConstructorParameters<F>) => PartialResolvedType<InstanceType<F>>>;\n\n/**\n * Creates a mock implementation of the provided function.\n *\n * @param method - The function to mock\n * @param implementation - Optional custom implementation that returns a partial result\n * @returns The mock state associated with the mocked function\n *\n * @remarks\n * This overload of the mockImplementation function allows for providing an implementation\n * that returns a partial result object. This is particularly useful when mocking functions\n * that return complex objects where only specific properties are relevant for testing.\n *\n * The implementation preserves the 'this' context from the original function, allowing\n * for proper method mocking on objects.\n *\n * @example\n * ```ts\n * interface User {\n * id: number;\n * name: string;\n * email: string;\n * }\n *\n * function getUser(id: number): User {\n * // real implementation\n * return { id, name: 'Real User', email: 'user@example.com' };\n * }\n *\n * const mockGetUser = mockImplementation(getUser, (id) => ({ id, name: 'Mock User' }));\n * const user = mockGetUser(123); // { id: 123, name: 'Mock User' }\n * ```\n *\n * @since 1.2.2\n */\n\nexport function mockImplementation<F extends FunctionType>(\n method: F,\n implementation?: (...args: Parameters<F>) => PartialResolvedType<ReturnType<F>>\n): MockState<(this: ThisParameterType<F>, ...args: Parameters<F>) => PartialResolvedType<ReturnType<F>>>;\n\n/**\n * Creates a mock for an element with an optional custom implementation.\n *\n * @template Element - The type of the element being mocked\n *\n * @param item - The element to mock\n * @param implementation - Optional custom implementation to replace the original element's behavior\n * @returns A {@link MockState} instance that controls and tracks the mock\n *\n * @remarks\n * The `mockImplementation` function creates a new {@link MockState} instance that wraps\n * around the provided element, allowing you to observe interactions with it and optionally\n * override its behavior. This is useful for isolating components during testing by\n * replacing their dependencies with controlled mocks.\n *\n * Responsibilities:\n * - Creating a trackable mock from any element\n * - Supporting custom implementation substitution\n * - Maintaining type safety between the original and mocked elements\n * - Enabling interaction tracking and verification capabilities\n * - Providing a fluent API for configuring mock behavior\n *\n * @example\n * ```ts\n * // Mock a simple value like export const testValue = 'original value'\n * const mockValue = xJet.mock(testValue);\n * mockValue.mockReturnValue(\"mocked value\");\n *\n * // Mock a function\n * const originalFn = (name: string) => `Hello, ${name}!`;\n * const mockedFn = xJet.mock(originalFn);\n *\n * // Configure custom implementation\n * mockedFn.mockImplementation((name: string) => `Hi, ${name}!`);\n *\n * test ('uses mocked function', () => {\n * const result = xJet.mock(testValue);\n * expect(result).toBe('Hi, World!');\n * expect(mockedFn).toHaveBeenCalledWith('World');\n * });\n * ```\n *\n * @see MockState\n * @see FunctionLikeType\n *\n * @since 1.2.0\n */\n\nexport function mockImplementation<Element = unknown>(\n item: Element,\n implementation?: () => Element\n): MockState<() => Element>;\n\n/**\n * Creates a mock for an item with an optional custom implementation.\n *\n * @param element - The element to mock\n * @param implementation - Optional custom implementation to replace the original item's behavior\n * @returns A {@link MockState} instance that controls and tracks the mock\n *\n * @remarks\n * The `mockImplementation` function creates a new {@link MockState} instance that wraps\n * around the provided item, allowing you to monitor interactions with it and optionally\n * override its implementation. This is particularly useful for testing components that\n * depend on external objects or functions by providing controlled behavior during tests.\n *\n * Responsibilities:\n * - Creating a trackable mock from any item (function, constructor, or value)\n * - Supporting custom implementation override capability\n * - Handling special cases for constructors with non-writable prototypes\n * - Enabling call tracking and verification functionality\n * - Maintaining the original reference in the parent object for restoration\n *\n * @example\n * ```ts\n * // Mock a function\n * const fetchData = async () => ({ id: 1, name: 'Test' });\n * const mockedFetch = xJet.mock(fetchData);\n *\n * // Mock with custom implementation\n * const mockedFetchCustom = xJet.mock(fetchData, async () => {\n * return { id: 2, name: 'Custom Test' };\n * });\n * ```\n *\n * @see MockState\n * @see FunctionLikeType\n * @see ConstructorLikeType\n *\n * @since 1.2.0\n */\n\nexport function mockImplementation(element: unknown, implementation?: FunctionType): MockState {\n if (!element) throw new ExecutionError('xJet.mock element is not defined');\n if (typeof element === 'function' && (element as MockState).xJetMock) return <MockState> element;\n\n const findObject = deepSearchObject(globalThis, element, (<FunctionType> element)?.name);\n if (!findObject) {\n throw new ExecutionError(\n 'Unable to mock this item: it was not found in any global object.\\n' +\n 'If you are trying to mock a Proxy object, please use xJet.spyOn() instead.'\n );\n }\n\n const { parent, key } = getOwnProperty(findObject.parent, findObject.key);\n const method = Reflect.get(parent, key);\n\n if (typeof method === 'function' && method.prototype && !Object.getOwnPropertyDescriptor(method, 'prototype')?.writable) {\n const mock = new MockState(\n (...args: Array<unknown>) => {\n return new (method as ConstructorLikeType<unknown, Array<unknown>>)(...args);\n },\n () => {\n Reflect.set(parent, key, method);\n }\n );\n\n Reflect.set(parent, key, mock);\n MockState.mocks.add(new WeakRef(mock));\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n }\n\n if (typeof method === 'function') {\n const mock = new MockState(<FunctionType> method, () => {\n Reflect.set(parent, key, method);\n });\n\n Reflect.set(parent, key, mock);\n MockState.mocks.add(new WeakRef(mock));\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n }\n\n const mock = mockDescriptorProperty(parent, key);\n if (implementation) mock.mockImplementation(implementation);\n\n return mock;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { PartialResolvedType } from '@shared/mock/interfaces/fn-mock.interface';\nimport type { ConstructorLikeType, FunctionLikeType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { MockProxyInterface, MockProxyStateInterface } from '@shared/mock/interfaces/spy-mock.interface';\n\n/**\n * Imports\n */\n\nimport { MockState } from '@shared/states/mock.state';\nimport { mockDescriptorProperty } from '@shared/mock/fn.mock';\nimport { ExecutionError } from '@shared/errors/execution.error';\nimport { deepSearchObject, getOwnProperty } from '@shared/components/object.component';\n\n/**\n * Checks if a property on an object is provided via a proxy mechanism rather than directly defined.\n *\n * @template T - The type of object being checked\n *\n * @param obj - The object to inspect\n * @param key - The property key to check on the object\n * @returns `true` if the property is provided by a proxy, `false` if directly defined\n *\n * @remarks\n * This function determines whether a property on an object is being provided through\n * a proxy mechanism (like a Proxy object or getter) rather than being directly defined\n * on the object itself. It works by checking if the key doesn't exist in the object's\n * own properties while still returning a non-undefined value when accessed.\n *\n * This is useful for:\n * - Detecting dynamically created properties\n * - Identifying properties provided via getters or proxies\n * - Distinguishing between direct properties and inherited/proxied ones\n *\n * @example\n * ```ts\n * // Regular object with direct property\n * const directObj = { name: 'Test' };\n * console.log(isProxyProperty(directObj, 'name')); // false\n *\n * // Object with proxy property\n * const handler = {\n * get(target, prop) {\n * if (prop === 'dynamic') return 'This is dynamic';\n * return target[prop];\n * }\n * };\n * const proxyObj = new Proxy({}, handler);\n * console.log(isProxyProperty(proxyObj, 'dynamic')); // true\n * ```\n *\n * @since 1.2.0\n */\n\nexport function isProxyProperty<T extends object>(obj: T, key: keyof T): boolean {\n return !(key in obj) && Reflect.get(obj, key) !== undefined;\n}\n\n/**\n * Determines if a value is a mock proxy created by the mocking system.\n *\n * @param value - The value to check\n * @returns `true` if the value is a mock proxy, `false` otherwise\n *\n * @remarks\n * This function checks if an object has the internal `__isMockProxy__` symbol property\n * which is added to all mock proxy objects created by the mocking framework.\n *\n * Mock proxies are specialized proxy objects that intercept property access\n * and method calls while providing mocking capabilities.\n *\n * @example\n * ```ts\n * const regularObject = { name: 'Test' };\n * const mockObject = createMock({ name: 'Test' });\n *\n * isMockProxy(regularObject); // false\n * isMockProxy(mockObject); // true\n * ```\n *\n * @since 1.2.2\n */\n\nexport function isMockProxy(value: Record<symbol, unknown>): boolean {\n return (value && typeof value === 'object' && '__isMockProxy__' in value);\n}\n\n/**\n * Creates a mock proxy that intercepts property access on an object.\n *\n * @template T - The type of the target object being proxied\n * @param target - The object to be proxied\n * @returns A MockProxyInterface that intercepts property access on the target\n *\n * @remarks\n * This function creates a proxy around an object that allows for interception\n * and customization of property access. The proxy maintains an internal state\n * that tracks mocked properties and provides mechanisms for customizing getter behavior.\n *\n * The proxy implements special properties:\n * - `__isMockProxy__`: Used to identify mock proxy objects\n * - `__MockMap__`: Provides access to the internal state for managing mocks\n *\n * Property access behavior:\n * 1. First checks if a custom getter is defined and uses it if available\n * 2. Then checks if the property has a specific mock implementation\n * 3. Falls back to the original property on the target object\n *\n * @example\n * ```ts\n * const user = { name: 'John', getAge: () => 30 };\n * const mockUser = createMockProxy(user);\n *\n * // Access original property\n * console.log(mockUser.name); // \"John\"\n *\n * // Add a mock for a property\n * const mockMap = mockUser.__MockMap__;\n * mockMap.mocks.set('getAge', () => 25);\n *\n * // Now returns the mock implementation\n * console.log(mockUser.getAge()); // 25\n * ```\n *\n * @since 1.2.2\n */\n\nexport function createMockProxy<T extends object>(target: T): MockProxyInterface {\n const state: MockProxyStateInterface = {\n mocks: new Map(),\n customGetter: null\n };\n\n const handler: ProxyHandler<T> = {\n get(_target, prop, receiver) {\n if (prop === '__isMockProxy__') return true;\n if (prop === '__MockMap__') return state;\n\n if (state.customGetter) {\n return state.customGetter(target, prop, receiver);\n }\n\n if (state.mocks.has(prop)) {\n return state.mocks.get(prop);\n }\n\n return Reflect.get(target, prop, receiver);\n }\n };\n\n return new Proxy({}, handler);\n}\n\n/**\n * Creates a spy on a property access for a proxied object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property to spy on\n *\n * @param target - The proxy object containing the property to spy on\n * @param prop - The name of the property to spy on\n * @returns A MockState object wrapping the property access\n *\n * @remarks\n * This specialized spy function is designed to work with properties accessed through proxy objects.\n * It handles the complexities of intercepting property access in proxied objects by:\n *\n * 1. Locating the proxy object in the global scope if needed\n * 2. Converting a normal object to a mock proxy if it isn't already one\n * 3. Setting up a spy on the property get operation\n *\n * The function ensures proper cleanup by providing a cleanup function that removes\n * the spy from the proxy's internal mock map when the spy is restored.\n *\n * @throws Error - When the target object cannot be found in the global scope\n *\n * @example\n * ```ts\n * // With an existing proxy\n * const proxyObj = createMockProxy({ getData: () => 'data' });\n * const spy = spyOnProxyGet(proxyObj, 'getData');\n *\n * proxyObj.getData(); // Spy records this call\n * spy.verify.called(); // Passes\n *\n * // With a normal object (will be converted to proxy)\n * const obj = { getValue: () => 42 };\n * const valueSpy = spyOnProxyGet(obj, 'getValue');\n *\n * obj.getValue(); // Spy records this call\n * valueSpy.verify.called(); // Passes\n * ```\n *\n * @since 1.2.2\n */\n\nexport function spyOnProxyGet<T extends Record<string | symbol, unknown>, K extends keyof T>(target: T, prop: K): MockState {\n const found = deepSearchObject(globalThis, target);\n if (!found) {\n throw new Error('xJet.spyOn item is not part of any global object');\n }\n\n if (!isMockProxy(target)) {\n const { parent, key } = getOwnProperty(found.parent, found.key);\n const method = Reflect.get(parent, key);\n\n Reflect.set(parent, key, createMockProxy(method as object));\n target = Reflect.get(parent, key) as T;\n }\n\n const proxy = target as MockProxyInterface;\n const mockState = new MockState(<FunctionType> target[prop], () => {\n proxy.__MockMap__?.mocks.delete(prop);\n }, 'xJet.spyOn(Proxy#get)');\n\n proxy.__MockMap__?.mocks.set(prop, mockState);\n\n return mockState;\n}\n\n/**\n * Creates a spy on a method or property of an object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property or method to spy on\n *\n * @param target - The object containing the method or property to spy on\n * @param key - The name of the method or property to spy on\n * @returns A MockState object wrapping the original method or property\n *\n * @remarks\n * This function creates a spy that wraps around an existing method or property on an object.\n * The spy tracks all calls to the method or access to the property while still executing the original functionality.\n *\n * - For methods: The spy preserves the original `this` context and passes all arguments to the original method\n * - For properties: The spy intercepts property access and returns the original value\n *\n * @example\n * ```ts\n * // Spying on a method\n * const user = {\n * getName: (prefix: string) => prefix + ' John'\n * };\n * const spy = xJet.spyOn(user, 'getName');\n *\n * user.getName('Mr.'); // Returns \"Mr. John\"\n * ```\n *\n * @since 1.0.0\n */\n\nexport function spyOnImplementation<T extends object, K extends keyof T>(target: T, key: K):\n T[K] extends FunctionType ?\n MockState<(\n this: ThisParameterType<T[K]>, ...args: Parameters<T[K]>\n ) => PartialResolvedType<ReturnType<T[K]>>>\n : MockState<() => T[K]>;\n\n/**\n * Creates a spy on a method or property of an object.\n *\n * @template T - The type of the target object\n * @template K - The key of the property or method to spy on\n *\n * @param target - The object containing the method or property to spy on\n * @param prop - The name of the method or property to spy on\n * @returns A MockState object wrapping the original method or property\n *\n * @remarks\n * This function creates a spy that wraps around an existing method or property on an object.\n * The spy tracks all calls to the method or access to the property while still executing the original functionality.\n *\n * - For methods: The spy preserves the original behavior while monitoring calls\n * - For properties: The spy intercepts property access via descriptor methods\n * - For class constructors: Special handling ensures proper constructor behavior\n *\n * The implementation handles various edge cases:\n * - Properties accessed through proxies\n * - Constructor functions with non-writable prototypes\n * - Properties that may exist in the prototype chain\n *\n * @throws ExecutionError - When:\n * - Target is not an object or function\n * - Property key is null\n * - Property doesn't exist on the target or its prototype chain\n *\n * @example\n * ```ts\n * // Spying on a method\n * const user = {\n * getName: () => { return 'John'; }\n * };\n * const spy = xJet.spyOn(user, 'getName');\n *\n * user.getName(); // Returns \"John\"\n * ```\n *\n * @since 1.0.0\n */\n\nexport function spyOnImplementation<T extends Record<string | symbol, unknown>, K extends keyof T>(target: T, prop: K): MockState {\n if (target == null || (typeof target !== 'object' && typeof target !== 'function'))\n throw new ExecutionError('Target must be an object or function');\n\n if (prop === null)\n throw new ExecutionError('Spied property/method key is required');\n\n let method = <MockState & T[K]> Reflect.get(target, prop);\n if(method?.xJetMock) return method;\n\n if (isProxyProperty(target, prop))\n return spyOnProxyGet(target, <string> prop);\n\n const { parent, key } = getOwnProperty(target, <string> prop);\n if (!(key in parent))\n throw new ExecutionError(`Property/method '${ String(key) }' does not exist on target`);\n\n method = <MockState & T[K]> Reflect.get(parent, prop);\n if (!method) throw new Error(`Property '${ String(key) }' does not exist in the provided object`);\n const descriptor = Object.getOwnPropertyDescriptor(parent, key);\n\n if (typeof method !== 'function' || descriptor?.get)\n return mockDescriptorProperty(parent, key);\n\n let fn: FunctionLikeType = method as FunctionLikeType;\n const protoDesc = Object.getOwnPropertyDescriptor(fn, 'prototype');\n\n if (fn.prototype && protoDesc && !protoDesc.writable) {\n fn = (...args: unknown[]): unknown =>\n new (method as ConstructorLikeType<unknown, unknown[]>)(...args);\n }\n\n const mockState = new MockState(fn, () => {\n Reflect.set(target, key, method);\n }, `xJet.spyOn(${ String(method.name) })`);\n\n MockState.mocks.add(new WeakRef(mockState));\n Reflect.set(parent, key, mockState);\n\n return mockState;\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionLikeType } from '@remotex-labs/xjet-expect';\nimport type { TimerInterface } from '@shared/services/interfaces/timer-service.interface';\n\n/**\n * Imports\n */\n\nimport { Injectable, inject } from '@symlinks/services/inject.service';\n\n/**\n * Provides a virtual timer system that mimics native `setTimeout`/`setInterval`\n * while allowing controlled execution for deterministic tests.\n *\n * @remarks\n * This service replaces the global timing functions with fake timers so that\n * time can be manually advanced and callbacks triggered predictably.\n * It is intended for unit testing scenarios where you need full control over\n * asynchronous timing without waiting in real time.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 1000);\n * advanceTimersByTime(1000); // logs 'done' immediately\n * useRealTimers();\n * ```\n *\n * @since 1.1.0\n */\n\n@Injectable({\n scope: 'singleton'\n})\nexport class TimerService {\n /**\n * Active timers managed by the fake timer engine.\n * @since 1.1.0\n */\n\n readonly timers = new Map<number, TimerInterface>();\n\n /**\n * Stores original `Date.now` to restore when real timers are re-enabled.\n * @since 1.1.0\n */\n\n readonly originalDateNow = Date.now;\n\n /**\n * Stores original global `setTimeout`.\n * @since 1.1.0\n */\n\n readonly originalSetTimeout = globalThis.setTimeout;\n\n /**\n * Stores original global `setInterval`.\n * @since 1.1.0\n */\n\n readonly originalSetInterval = globalThis.setInterval;\n\n /**\n * Stores original global `clearTimeout`.\n * @since 1.1.0\n */\n\n readonly originalClearTimeout = globalThis.clearTimeout;\n\n /**\n * Stores original global `clearInterval`.\n * @since 1.1.0\n */\n\n readonly originalClearInterval = globalThis.clearInterval;\n\n /**\n * Simulated current timestamp for the fake timers.\n * @since 1.1.0\n */\n\n private now = 0;\n\n /**\n * Incremental id used to register timers uniquely.\n * @since 1.1.0\n */\n\n private nextId = 1;\n\n /**\n * Replaces the global timer functions with in-memory fakes.\n *\n * @remarks\n * After calling this method, any calls to `setTimeout`, `setInterval`,\n * `clearTimeout`, or `clearInterval` will be intercepted and stored in the\n * {@link timers} map instead of scheduling real OS timers.\n * This allows tests to control time progression manually using\n * {@link advanceTimersByTime}, {@link runAllTimers}, or\n * {@link runOnlyPendingTimers}.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * const id = setTimeout(() => console.log('done'), 1000);\n * timerService.advanceTimersByTime(1000); // logs \"done\" immediately\n * ```\n *\n * @since 1.1.0\n */\n\n useFakeTimers(): void {\n const setTimeout = (cb: FunctionLikeType<void>, delay: number = 0, ...args: Array<unknown>): number => {\n const id = this.nextId++;\n this.timers.set(id, { id, callback: cb, time: this.now + delay, interval: null, args: args ?? [] });\n\n return id;\n };\n\n const setInterval = (cb: FunctionLikeType<void>, interval: number = 0): number => {\n const id = this.nextId++;\n this.timers.set(id, { id, callback: cb, time: this.now + interval, interval, args: [] });\n\n return id;\n };\n\n const clearTimeout = (id: number): void => {\n this.timers.delete(id);\n };\n\n\n const clearInterval = (id: number): void => {\n this.timers.delete(id);\n };\n\n const global = <Record<string, unknown>> globalThis;\n global.setTimeout = setTimeout;\n global.setInterval = setInterval;\n global.clearTimeout = clearTimeout;\n global.clearInterval = clearInterval;\n }\n\n /**\n * Restores the original global timer APIs and `Date.now`.\n *\n * @remarks\n * This method undoes the effects of {@link useFakeTimers}, re-binding\n * the native implementations of `setTimeout`, `setInterval`,\n * `clearTimeout`, `clearInterval`, and `Date.now`.\n * After calling this, timers once again behave according to real system\n * time and manual advancement methods such as\n * {@link advanceTimersByTime} no longer apply.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * // ...run tests with controlled time...\n * timerService.useRealTimers(); // restore native timers\n * ```\n *\n * @since 1.1.0\n */\n\n useRealTimers(): void {\n this.timers.clear();\n globalThis.setTimeout = this.originalSetTimeout;\n globalThis.clearTimeout = this.originalClearTimeout;\n globalThis.setInterval = this.originalSetInterval;\n globalThis.clearInterval = this.originalClearInterval;\n Date.now = this.originalDateNow;\n }\n\n /**\n * Clears all active fake timers.\n *\n * @remarks\n * This method removes every timer currently stored in {@link timers},\n * effectively resetting the fake timer state without advancing time.\n * It is useful for cleaning up between tests to ensure no lingering\n * scheduled callbacks remain.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * clearAllTimers(); // removes all scheduled timers\n * advanceTimersByTime(100); // nothing happens\n * ```\n *\n * @since 1.3.0\n */\n\n clearAllTimers(): void {\n this.timers.clear();\n }\n\n /**\n * Advances the simulated clock by a specific number of milliseconds and\n * executes all timers whose scheduled time has elapsed.\n *\n * @remarks\n * Use this method after calling {@link useFakeTimers} to fast-forward the\n * internal clock without waiting in real time.\n * Any `setTimeout` or `setInterval` callbacks scheduled within the\n * advanced period will run immediately in order of their scheduled time.\n *\n * @param ms - The number of milliseconds to move the simulated time forward.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => console.log('done'), 500);\n * timerService.advanceTimersByTime(500); // logs \"done\"\n * ```\n *\n * @since 1.1.0\n */\n\n advanceTimersByTime(ms: number) : void {\n this.now += ms;\n this.runDueTimers();\n }\n\n /**\n * Executes every scheduled timer until none remain.\n *\n * @remarks\n * This method repeatedly advances the simulated clock to the next\n * scheduled timer and runs its callback until the {@link timers} map\n * is empty.\n * It is useful when you want to immediately flush **all** pending\n * `setTimeout` or `setInterval` callbacks regardless of their delay,\n * without specifying a time increment.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n * timerService.runAllTimers(); // logs \"A\" then \"B\"\n * ```\n *\n * @since 1.1.0\n */\n\n runAllTimers(): void {\n while (this.timers.size > 0) {\n this.now = Math.min(...Array.from(this.timers.values()).map(t => t.time));\n this.runDueTimers();\n }\n }\n\n /**\n * Executes only the timers that are currently pending at the time of call,\n * without running any new timers that may be scheduled by those callbacks.\n *\n * @remarks\n * Unlike {@link runAllTimers}, this method captures the set of timers\n * that exist when the method is invoked and restricts execution to that\n * initial set.\n * If any of those timers schedule additional timers while running,\n * the newly scheduled ones will **not** be executed during this call.\n *\n * @example\n * ```ts\n * timerService.useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n *\n * timerService.runOnlyPendingTimers();\n * // Logs only \"first\" because \"second\" was created afterward.\n * ```\n *\n * @since 1.1.0\n */\n\n runOnlyPendingTimers(): void {\n const pendingTimers = new Set(this.timers.keys());\n\n while (pendingTimers.size > 0) {\n const nextTimerTimes = Array.from(this.timers.values())\n .filter(t => pendingTimers.has(t.id))\n .map(t => t.time);\n\n if (nextTimerTimes.length === 0) break;\n\n this.now = Math.min(...nextTimerTimes);\n this.runDueTimers(pendingTimers);\n\n for (const id of pendingTimers) {\n if (!this.timers.has(id)) pendingTimers.delete(id);\n }\n }\n }\n\n /**\n * Asynchronous equivalent of {@link runAllTimers}.\n *\n * @remarks\n * This method first yields to the event loop to allow any pending promises\n * to resolve before executing all remaining fake timers.\n * It ensures a deterministic sequence when timers and microtasks coexist.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * Promise.resolve().then(() => console.log('microtask'));\n * setTimeout(() => console.log('timer'), 0);\n * await timerService.runAllTimersAsync();\n * // Logs:\n * // microtask\n * // timer\n * ```\n *\n * @since 1.3.0\n */\n\n async runAllTimersAsync(): Promise<void> {\n await Promise.resolve();\n this.runAllTimers();\n }\n\n /**\n * Asynchronous equivalent of {@link runOnlyPendingTimers}.\n *\n * @remarks\n * This method first yields to the event loop to allow any pending promises\n * to resolve before executing only currently pending fake timers.\n * Timers scheduled during execution will not run until explicitly advanced later.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n * await timerService.runOnlyPendingTimersAsync();\n * // Logs:\n * // first\n * ```\n *\n * @since 1.3.0\n */\n\n async runOnlyPendingTimersAsync(): Promise<void> {\n await Promise.resolve();\n this.runOnlyPendingTimers();\n }\n\n /**\n * Executes all timers whose scheduled time is less than or equal to the\n * current simulated time (`this.now`).\n *\n * @remarks\n * This internal method is called by {@link advanceTimersByTime},\n * {@link runAllTimers}, and {@link runOnlyPendingTimers} to trigger\n * due timers.\n * If `limitTimers` are provided, only timers included in that set are executed.\n * Repeating timers (`setInterval`) are rescheduled automatically until\n * their next execution time exceeds the current simulated time.\n *\n * @param limitTimers - Optional set of timer IDs to restrict execution.\n *\n * @internal\n * @since 1.1.0\n */\n\n private runDueTimers(limitTimers?: Set<number>): void {\n let executed = true;\n while (executed) {\n executed = false;\n\n const timers = Array.from(this.timers.values()).sort((a, b) => a.time - b.time);\n\n for (const timer of timers) {\n if (!this.timers.has(timer.id)) continue;\n if (limitTimers && !limitTimers.has(timer.id)) continue;\n\n if (timer.time <= this.now) {\n if (timer.interval !== null) {\n while (timer.time <= this.now) {\n timer.callback();\n timer.time += timer.interval;\n }\n } else {\n timer.callback();\n this.timers.delete(timer.id);\n }\n executed = true;\n }\n }\n }\n }\n}\n\n/**\n * Globally enables fake timers using the shared {@link TimerService}.\n *\n * @remarks\n * After calling this function, all calls to `setTimeout`, `setInterval`,\n * `clearTimeout`, and `clearInterval` will be intercepted by the\n * {@link TimerService} and stored in-memory instead of executing in real time.\n * This allows deterministic testing by manually advancing time with\n * {@link advanceTimersByTime}, {@link runAllTimers}, or\n * {@link runOnlyPendingTimers}.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 1000);\n * advanceTimersByTime(1000); // logs \"done\" immediately\n * ```\n *\n * @since 1.1.0\n */\n\nexport function useFakeTimers(): void {\n inject(TimerService).useFakeTimers();\n}\n\n/**\n * Restores real timers globally using the shared {@link TimerService}.\n *\n * @remarks\n * This function undoes the effects of {@link useFakeTimers}, restoring the\n * native implementations of `setTimeout`, `setInterval`, `clearTimeout`,\n * `clearInterval`, and `Date.now`.\n * After calling this, timers once again behave according to real system time,\n * and manual advancement methods like {@link advanceTimersByTime} no longer apply.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * // ...run tests with controlled time...\n * useRealTimers(); // restore native timers\n * ```\n *\n * @since 1.1.0\n */\n\nexport function useRealTimers(): void {\n inject(TimerService).useRealTimers();\n}\n\n/**\n * Executes all timers currently registered in the {@link TimerService}.\n *\n * @remarks\n * This function repeatedly runs all pending `setTimeout` and `setInterval`\n * callbacks until no timers remain.\n * It is equivalent to calling {@link TimerService.runAllTimers} on the\n * injected service instance and is useful for immediately flushing\n * all scheduled timers in tests.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n * runAllTimers(); // logs \"A\" then \"B\"\n * ```\n *\n * @since 1.1.0\n */\n\nexport function runAllTimers(): void {\n inject(TimerService).runAllTimers();\n}\n\n/**\n * Removes all scheduled fake timers from the {@link TimerService}.\n *\n * @remarks\n * This function clears all active timers registered in the shared timer service,\n * effectively canceling any pending callbacks that would have run during\n * timer advancement.\n *\n * It's useful for resetting the fake timer state between test cases to ensure\n * no lingering timers affect further tests or for scenarios where you\n * need to abort all pending operations.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('A'), 100);\n * setTimeout(() => console.log('B'), 200);\n *\n * clearAllTimers(); // removes all scheduled timers\n * advanceTimersByTime(1000); // nothing happens, not show any logs\n * ```\n *\n * @since 1.3.0\n */\n\nexport function clearAllTimers(): void {\n inject(TimerService).clearAllTimers();\n}\n\n/**\n * Executes only the timers that are pending at the time of invocation.\n *\n * @remarks\n * This function runs the callbacks of timers that exist when the function\n * is called, without executing any new timers that may be scheduled\n * during their execution.\n * It delegates to {@link TimerService.runOnlyPendingTimers} on the injected\n * service instance.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n *\n * runOnlyPendingTimers();\n * // Logs only \"first\"; \"second\" is not executed yet\n * ```\n *\n * @since 1.1.0\n */\n\nexport function runOnlyPendingTimers(): void {\n inject(TimerService).runOnlyPendingTimers();\n}\n\n/**\n * Advances the simulated time by a specified number of milliseconds and\n * executes all timers that are due.\n *\n * @remarks\n * This function delegates to {@link TimerService.advanceTimersByTime}\n * on the injected service instance.\n * It is intended to be used after {@link useFakeTimers} to fast-forward\n * time in tests without waiting for real timers.\n *\n * @param ms - The number of milliseconds to advance (default is `0`).\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => console.log('done'), 500);\n * advanceTimersByTime(500); // logs \"done\"\n * ```\n *\n * @since 1.1.0\n */\n\nexport function advanceTimersByTime(ms: number = 0): void {\n inject(TimerService).advanceTimersByTime(ms);\n}\n\n/**\n * Asynchronous equivalent of {@link runAllTimers}.\n *\n * @remarks\n * Yields to the event loop before running all pending fake timers.\n * Useful when working with both Promises and fake timers.\n *\n * @example\n * ```ts\n * xJet.useFakeTimers();\n * Promise.resolve().then(() => console.log('promise done'));\n * setTimeout(() => console.log('timeout done'), 0);\n * await xJet.runAllTimersAsync();\n * // Logs:\n * // promise done\n * // timeout done\n * ```\n *\n * @since 1.3.0\n */\n\nexport async function runAllTimersAsync(): Promise<void> {\n await inject(TimerService).runAllTimersAsync();\n}\n\n/**\n * Asynchronous equivalent of {@link runOnlyPendingTimers}.\n *\n * @remarks\n * Yields to the event loop before running only timers that are currently pending.\n * Any timers scheduled by those callbacks will not be executed until a later call.\n *\n * @example\n * ```ts\n * useFakeTimers();\n * setTimeout(() => {\n * console.log('first');\n * setTimeout(() => console.log('second'), 100);\n * }, 100);\n * await runOnlyPendingTimersAsync();\n * // Logs only \"first\"\n * ```\n *\n * @since 1.3.0\n */\n\nexport async function runOnlyPendingTimersAsync(): Promise<void> {\n await inject(TimerService).runOnlyPendingTimersAsync();\n}\n", "/**\n * A regular expression pattern used to match variable-like strings prefixed with a `$` symbol.\n *\n * @default /\\$([#\\\\w.])+/g\n *\n * @see resolveVariable\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nconst VARIABLE_PATTERN = /\\$([#\\w.])+/g;\n\n/**\n * Formats a given value into a human-readable string representation.\n *\n * @param value - The value to be formatted\n * @returns The formatted string representation of the input value\n *\n * @remarks\n * This method ensures that non-string values are converted into a JSON string with\n * indentation for easier readability. If the input is a string, it is returned as-is.\n *\n * @example\n * ```ts\n * // String input is returned unchanged\n * const str = prettyFormat(\"hello\"); // Returns: \"hello\"\n *\n * // Objects are converted to indented JSON\n * const obj = prettyFormat({ name: \"John\", age: 30 });\n * // Returns:\n * // {\n * // \"name\": \"John\",\n * // \"age\": 30\n * // }\n * ```\n *\n * @see printf\n *\n * @since 1.0.0\n */\n\nexport function prettyFormat(value: unknown): string {\n if (typeof value === 'string') return value;\n\n return JSON.stringify(value, null, 4);\n}\n\n/**\n * Retrieves a value from a nested object structure based on a specified path.\n *\n * @param data - The object containing the nested data to traverse\n * @param path - An array of strings representing the sequence of keys to access the desired value\n * @returns The value found at the specified path within the object, or `undefined` if the path does not exist\n *\n * @remarks\n * This function safely traverses the given object structure without throwing errors\n * for missing keys or null/undefined values.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * profile: {\n * name: \"John Doe\",\n * email: \"john@example.com\"\n * }\n * }\n * };\n *\n * const name = getValueByPath(data, [\"user\", \"profile\", \"name\"]);\n * // Returns: \"John Doe\"\n *\n * const missing = getValueByPath(data, [\"user\", \"settings\", \"theme\"]);\n * // Returns: undefined\n * ```\n *\n * @see resolveVariable\n *\n * @since 1.0.0\n */\n\nexport function getValueByPath(data: Record<string, unknown>, path: string[]): unknown {\n if (!path.length || !data) return undefined;\n\n try {\n return path.reduce((obj, key) => {\n if (obj === null || obj === undefined || typeof obj !== 'object') {\n throw new Error('Path traversal failed');\n }\n\n return (obj as Record<string, unknown>)[key];\n }, data as unknown);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolves a variable token into its corresponding value from the provided data object.\n *\n * @param token - The variable token to resolve\n * @param data - The object containing data used for resolving the variable token\n * @param arrayIndex - The index value to be used if the token represents an array index (`$#`)\n * @returns The resolved value as a string, or the original token if resolution fails\n *\n * @remarks\n * This function assumes the use of dot notation in token paths to access nested properties\n * within the `data` object. Tokens starting with `$#` will be replaced by the array index.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * name: \"John\"\n * }\n * };\n *\n * const value1 = resolveVariable(\"$user.name\", data, 0);\n * // Returns: \"John\"\n *\n * const value2 = resolveVariable(\"$#\", data, 5);\n * // Returns: \"5\"\n * ```\n *\n * @see getValueByPath\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nexport function resolveVariable(token: string, data: Record<string, unknown>, arrayIndex: number): string {\n if (!token || typeof <unknown> token !== 'string' || !token.startsWith('$'))\n return token;\n\n if (token === '$#')\n return String(arrayIndex);\n\n const propertyPath = token.slice(1).split('.');\n const resolvedValue = getValueByPath(data, propertyPath);\n\n if (resolvedValue === undefined || resolvedValue === null) {\n return token;\n }\n\n if (typeof resolvedValue === 'object') {\n try {\n return JSON.stringify(resolvedValue, (key, value) => {\n if (key && typeof value === 'object')\n return '[Object]';\n\n return value;\n });\n } catch {\n return String(resolvedValue);\n }\n }\n\n return String(resolvedValue);\n}\n\n/**\n * Replaces variable placeholders within a template string with corresponding values from a provided data object.\n *\n * @param template - The template string containing variable placeholders\n * @param data - An object mapping variable names to their respective values\n * @param arrayIndex - The index to be applied when resolving variables that reference array values\n * @returns The resulting string with all variable placeholders replaced by their resolved values\n *\n * @throws Error - If a required variable cannot be resolved\n *\n * @remarks\n * The function uses a regular expression to identify variable placeholders within the template string\n * and replaces them with corresponding values derived from the `data` object.\n *\n * @example\n * ```ts\n * const data = {\n * user: {\n * name: \"Jane\",\n * id: 42\n * },\n * status: \"active\"\n * };\n *\n * const result = interpolateVariables(\"User $user.name ($user.id) is $status\", data, 0);\n * // Returns: \"User Jane (42) is active\"\n * ```\n *\n * @see VARIABLE_PATTERN\n * @see resolveVariable\n *\n * @since 1.0.0\n */\n\nexport function interpolateVariables(template: string, data: Record<string, unknown>, arrayIndex: number): string {\n return template.replace(\n VARIABLE_PATTERN, (variableToken) => resolveVariable(variableToken, data, arrayIndex)\n );\n}\n\n/**\n * Formats a given string by interpolating it with the provided parameters.\n *\n * @param description - The format string containing variables or tokens to be replaced\n * @param params - An array of values to interpolate or substitute into the format string\n * @param index - An index used for specific token replacements (e.g., `%#`)\n * @returns The formatted string after performing substitutions and formatting\n *\n * @remarks\n * This function supports two formatting approaches:\n * 1. `$variable` style interpolation using the first object in the `params` array\n * 2. Printf-style format specifiers with the following options:\n * - `%p`: Pretty prints a value\n * - `%s`: Converts value to a string\n * - `%d`: Converts value to a numeric string\n * - `%i`: Converts value to an integer string (floor of the number)\n * - `%f`: Converts value to a floating-point string\n * - `%j`: Converts value to its JSON representation\n * - `%o`: Outputs the object's `toString` representation\n * - `%#`: Replaced with the provided `index`\n * - `%%`: Escapes the `%` character\n *\n * If the `description` contains `$`-style variables, it will interpolate those using the first object in the `params` array.\n * This behavior does not apply if the string also contains `%%`.\n *\n * @example\n * ```ts\n * // Format with printf-style specifiers\n * const result1 = printf(\"Value: %s, Number: %d\", [\"test\", 42], 0);\n * // Returns: \"Value: test, Number: 42\"\n *\n * // Format with variable interpolation\n * const data = { name: \"Alice\", age: 30 };\n * const result2 = printf(\"Name: $name, Age: $age\", [data], 0);\n * // Returns: \"Name: Alice, Age: 30\"\n * ```\n *\n * @see prettyFormat\n * @see interpolateVariables\n *\n * @since 1.0.0\n */\n\nexport function printf(description: string, params: Array<unknown>, index: number): string {\n let paramIndex = 0;\n // Handle $variable style interpolation first\n if (description.includes('$') && !description.includes('%%')) {\n description = interpolateVariables(description, <Record<string, unknown>> params[0], index);\n }\n\n return description.replace(/%([psdifjo#%])/g, (match, format) => {\n if (format === '%') return '%';\n if (format === '#') return String(index);\n\n const value = params[paramIndex++];\n switch (format) {\n case 'p':\n return prettyFormat(value);\n case 's':\n return String(value);\n case 'd':\n return Number(value).toString();\n case 'i':\n return Math.floor(Number(value)).toString();\n case 'f':\n return Number(value).toString();\n case 'j':\n return JSON.stringify(value);\n case 'o':\n return Object.prototype.toString.call(value);\n default:\n return match;\n }\n });\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { InvokeType } from '@shared/directives/interfaces/each-directive.interface';\n\n/**\n * Imports\n */\n\nimport { printf } from '@shared/components/printf.component';\n\n/**\n * Converts a template string and input data into an array of structured objects\n *\n * @param templateString - Template string containing column headings separated by pipe characters\n * @param inputData - Array of values to be organized according to the template structure\n * @returns Array of objects where each object represents a row with properties named after the headings\n *\n * @throws Error - When template headings are empty or missing pipe delimiters\n * @throws Error - When the input data length is not a multiple of the headings length\n *\n * @example\n * ```ts\n * const template = parseTemplate(`name|age|role`, ['John', 30, 'Developer', 'Jane', 25, 'Designer']);\n * // Returns: [\n * // { name: 'John', age: 30, role: 'Developer' },\n * // { name: 'Jane', age: 25, role: 'Designer' }\n * // ]\n * ```\n *\n * @see each - Function that uses parseTemplate for test case generation\n *\n * @since 1.0.0\n */\n\nexport function parseTemplate(templateString: TemplateStringsArray, inputData: Array<unknown>): Array<Record<string, unknown>> {\n // Extract the column headings and remove any leading/trailing whitespace\n const headings: string[] = templateString[0].split('|').map((h: string) => h.trim());\n if (headings.length === 0 || headings.some((h) => h === ''))\n throw new Error('Template string headings must not be empty and should contain pipe delimiters.');\n\n if ((inputData.length % headings.length) !== 0)\n throw new Error('Not enough arguments supplied for given headings.');\n\n return Array.from({ length: inputData.length / headings.length }, (_, rowIndex) => {\n return headings.reduce((acc, heading, columnIndex) => {\n acc[heading] = inputData[rowIndex * headings.length + columnIndex];\n\n return acc;\n }, {} as Record<string, unknown>);\n });\n}\n\n/**\n * Executes a function block as a test case with the specified description\n *\n * @template T - Type extending Array of unknown values\n * @param executor - The function that will execute each test case\n * @param args - Arguments representing test cases or a tagged template literal\n * @returns A function that accepts a test name, test block function, and optional timeout\n *\n * @throws Error - When called with fewer than 2 arguments\n *\n * @remarks\n * This method provides a way to directly invoke a test function with optional arguments.\n * It is typically used with the `each` function to create parameterized test cases.\n * The provided description will be used for test reporting and identification.\n *\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * // As part of the each function with direct arguments\n * test.each(1, 2, 3)('test with %s', (val) => {\n * expect(val).toBeGreaterThan(0);\n * });\n *\n * test.each(\n * { name: 'John', age: 30 },\n * { name: 'Jane', age: 25 }\n * )('User %s is %s years old', (name, age) => {\n * expect(typeof name).toBe('string');\n * expect(typeof age).toBe('number');\n * });\n *\n * test.each`\n * a | b | sum\n * ${ 1 } | ${ 2 } | ${ 3 }\n * ${ 2 } | ${ 5 } | ${ 7 }\n * `('adds $a + $b -> $sum', ({ a, b, sum }) => {\n * expect(a + b).toBe(sum);\n * });\n *\n * describe.each` a | b | expected ${ 1 } | ${ 2 } | ${ 3 } ${ 2 } | ${ 3 } | ${ 5 }`\n * ('%# adds $a and $b to get $expected', ({ a, b, expected }) => {\n * test('calculates sum', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see InvokeType - Type definition for the executor function\n * @see FunctionType - Type definition for the test block function\n * @see parseTemplate - Function used to parse tagged template literals\n *\n * @since 1.0.0\n */\n\nexport function each<T extends Array<unknown>>(executor: InvokeType, ...args: T) {\n if (args.length < 2) {\n throw new Error('`.each` must be called with at leas 2 argument or Tagged Template Literal.');\n }\n\n // eslint-disable-next-line\n const isTemplateStrings = args[0] instanceof Array && (<any> args[0]).raw !== undefined;\n const cases: Array<unknown> = isTemplateStrings ? parseTemplate(<TemplateStringsArray> args.shift(), args) : args;\n\n return (name: string, blockFn: FunctionType, timeout?: number): void => {\n cases.forEach((testCase, index) => {\n const parseArgs = Array.isArray(testCase) ? testCase : [ testCase ];\n executor(printf(name, parseArgs, Number(index)), blockFn, parseArgs, timeout);\n });\n };\n}\n", "export class TimeoutError extends Error {\n constructor(timeout: number, at: string, stack: string = '') {\n super(`Exceeded timeout of ${ timeout } ms at ${ at }`);\n\n // Ensure a correct prototype chain (important for `instanceof`)\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'xJetTimeoutError';\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n this.name = 'xJetFailingError';\n if(stack) {\n this.stack = `${ this.name }: ${ this.message }\\n${ stack }`;\n }\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionLikeType } from '@remotex-labs/xjet-expect';\n\n/**\n * Imports\n */\n\nimport { TimeoutError } from '@errors/timeout.error';\nimport { inject } from '@symlinks/services/inject.service';\nimport { TimerService } from '@shared/services/timer.service';\n\n\n/**\n * Executes a given asynchronous or synchronous task with an optional timeout constraint.\n *\n * @typeParam T - The resolved value type.\n *\n * @param task - Either a function that returns a value or promise, or a promise itself.\n * @param delay - Timeout in milliseconds, or `-1` to disable the timeout.\n * @param at - A contextual label (e.g., method name or operation name) to aid debugging.\n * @param stack - Optional stack trace to provide more detailed error context.\n *\n * @throws {@link TimeoutError} If the task does not complete within the specified `delay`\n * (only when `delay` is not `-1`).\n *\n * @remarks\n * The function accepts either:\n * - a function returning a value or a promise, or\n * - a promise directly.\n *\n * If `delay` is `-1`, no timeout is applied. Otherwise the task is raced against\n * a timer and a {@link TimeoutError} is thrown on expiry.\n *\n * @example\n * ```ts\n * // Passing a function\n * await withTimeout(\n * () => fetchData(),\n * 5000,\n * 'fetchData'\n * );\n *\n * // Passing a promise directly\n * await withTimeout(\n * fetchData(),\n * 5000,\n * 'fetchDataDirect'\n * );\n *\n * // No timeout\n * await withTimeout(fetchData(), -1, 'fetchDataNoTimeout');\n * ```\n *\n * @since 1.1.0\n */\n\nexport async function withTimeout<T>(\n task: FunctionLikeType<T | Promise<T>> | Promise<T> | T, delay: number, at: string, stack?: string\n): Promise<T> {\n const timers = inject(TimerService);\n\n const taskPromise =\n typeof task === 'function'\n ? Promise.resolve((task as FunctionLikeType<T | Promise<T>>)())\n : Promise.resolve(task);\n\n if (delay === -1 || !timers.originalSetTimeout) {\n return taskPromise;\n }\n\n let timeoutId: ReturnType<typeof setTimeout>;\n const timeoutPromise = new Promise<never>((_, reject) => {\n timeoutId = timers.originalSetTimeout?.(\n () => reject(new TimeoutError(delay, at, stack)),\n delay\n );\n });\n\n try {\n return await Promise.race([ taskPromise, timeoutPromise ]);\n } finally {\n timers.originalClearTimeout?.(timeoutId!);\n }\n}\n\n", "/**\n * Imports\n */\n\nimport { ExecutionError } from '@shared/errors/execution.error';\n\n\nexport class FailingError extends ExecutionError {\n\n\n constructor(stack: string) {\n super('Failing test passed even though it was supposed to fail. Remove `.failing` to remove error.');\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, FailingError);\n }\n\n this.name = 'xJetFailingError';\n this.stack = `${ this.name }: ${ this.message }\\n${ stack }`;\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { TestFlagsType } from '@shared/models/interfaces/test-model.interface';\nimport type { ContextInterface } from '@shared/models/interfaces/describe-model.interface';\n\n/**\n * Imports\n */\n\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { withTimeout } from '@components/timeout.component';\nimport { FailingError } from '@shared/errors/failing.error';\nimport { MessageType } from '@messages/constants/report.constant';\nimport { emitEvent, emitStatus } from '@shared/services/emit.service';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\nimport { TestExecutionType } from '@shared/models/constants/test-model.constants';\nimport { type ContextType, type FunctionLikeType, type FunctionType, isPromise } from '@remotex-labs/xjet-expect';\n\n/**\n * Represents a test case within the testing framework that manages execution,\n * timing, and reporting of individual tests.\n *\n * @example\n * ```ts\n * const test = new TestModel(\n * 'should validate user input correctly',\n * async () => {\n * const result = await validateInput('test@example.com');\n * expect(result.isValid).toBe(true);\n * },\n * 2000\n * );\n *\n * // Set ancestry to show the test's location in the test hierarchy\n * test.ancestry = ['Authentication', 'Input Validation'];\n *\n * // Execute the test\n * await test.execute();\n * ```\n *\n * @remarks\n * The TestModel is responsible for tracking test execution time, handling timeouts,\n * managing test context, and reporting test status through the emit service.\n * It supports both synchronous and promise-based test implementations.\n *\n * @throws FailingError - When a test fails due to assertions or errors\n *\n * @see ContextInterface\n * @see EmitActionEventType\n * @see EmitStatusEventType\n * @see InvocationLocationType\n *\n * @since 1.0.0\n */\n\nexport class TestModel {\n /**\n * Stores the hierarchical path of parent test descriptions that contain this test\n *\n * @default []\n * @since 1.0.0\n */\n\n readonly ancestry: Array<string> = [];\n\n /**\n * Stores information about where this test is being executed in the source code\n *\n * @see InvocationLocationType\n * @since 1.0.0\n */\n\n private executionLocation: string = '';\n\n /**\n * Timestamp when test execution started, measured in milliseconds\n *\n * @default 0\n * @since 1.0.0\n */\n\n private executionStartTime: number = 0;\n\n /**\n * Creates a new instance of the TestModel to represent an executable test.\n *\n * @param description - The test description that explains the purpose of the test\n * @param testImplementation - The function containing the actual test code to be executed\n * @param timeoutDuration - The maximum time in milliseconds that the test is allowed to run\n * @param testParameters - An array of parameters to be passed to the test implementation\n * @param testOptions - Configuration options that control test execution behavior\n *\n * @example\n * ```ts\n * const test = new TestModel(\n * 'should calculate the correct sum',\n * () => expect(sum(2, 2)).toBe(4),\n * 5000\n * );\n * ```\n *\n * @since 1.0.0\n */\n\n constructor(\n readonly description: string,\n private readonly testImplementation: FunctionType,\n private readonly timeoutDuration: number,\n private readonly testParameters: unknown[] = [],\n private readonly testOptions: TestFlagsType = {}\n ) {}\n\n /**\n * Provides access to the test configuration options.\n *\n * @returns The test configuration options that control test execution behavior\n *\n * @since 1.0.0\n */\n\n get options(): TestFlagsType {\n return this.testOptions;\n }\n\n /**\n * Sets the location where the test is being executed.\n *\n * @param location - The execution location information containing position details\n *\n * @see InvocationLocationType\n * @since 1.0.0\n */\n\n setExecutionLocation(location: string): void {\n this.executionLocation = location;\n }\n\n /**\n * Applies execution control options to the test, allowing it to be skipped or run exclusively.\n *\n * @param skip - Flag indicating whether the test should be skipped during execution\n * @param only - Flag indicating whether only this test should be executed\n *\n * @remarks\n * This method uses logical OR assignment (||=) to ensure options are only set to true and\n * never reset from true to false. Existing flag values take precedence.\n *\n * @example\n * ```ts\n * testInstance.applyExecutionFlags(true, false); // Will mark test to be skipped\n * testInstance.applyExecutionFlags(false, true); // Will mark test to run exclusively\n * ```\n *\n * @see TestFlagsType\n * @since 1.0.0\n */\n\n applyExecutionFlags(skip?: boolean, only?: boolean): void {\n this.testOptions.skip ||= skip;\n this.testOptions.only ||= only;\n }\n\n /**\n * Sets the ancestry for this test by adding parent test descriptions to the ancestry chain.\n *\n * @param parentTests - Array of parent test description strings representing the test hierarchy\n *\n * @example\n * ```ts\n * const childTest = new TestModel(\"should work\", () => {}, 5000);\n * childTest.setAncestry([\"describe block A\", \"describe block B\"]);\n * ```\n *\n * @since 1.0.0\n */\n\n setAncestry(parentTests: string[]): void {\n this.ancestry.push(...parentTests);\n }\n\n /**\n * Executes the test within the specified context, managing test lifecycle and status reporting.\n *\n * @param context - The test execution context containing shared state and utilities\n * @param runLifecycleHooks - Function that runs before/after hooks at appropriate times\n * @param isExclusiveMode - Flag indicating if tests are running in exclusive mode (only marked tests)\n * @returns Promise that resolves when the test execution completes\n *\n * @throws Error - If any unhandled exceptions occur during test execution that aren't captured\n *\n * @remarks\n * The method tracks execution time, manages test lifecycle, handles skipping logic, and processes\n * test results. It also notifies about test status changes through observer pattern implementation.\n *\n * @example\n * ```ts\n * // Running a test with context and lifecycle hooks\n * await testInstance.run(\n * testContext,\n * async (hookType, ctx) => {\n * await runHooks(hookType, ctx);\n * },\n * false\n * );\n * ```\n *\n * @see HookType\n * @see ActionType\n * @see ContextInterface\n *\n * @since 1.0.0\n */\n\n async run(\n context: ContextType<ContextInterface>,\n runLifecycleHooks: FunctionLikeType<Promise<void>, [ HookType, ContextType<ContextInterface> ]>,\n isExclusiveMode: boolean = false\n ): Promise<void> {\n inject(SuiteState).test = this;\n this.executionStartTime = Date.now();\n\n if (this.shouldSkipDueToSetupErrors(context))\n return;\n\n if (this.determineSkipAction(isExclusiveMode)) return;\n\n try {\n await this.executeTestWithLifecycle(context, runLifecycleHooks);\n this.validateTestOutcome();\n } catch (error) {\n this.notifyTestFailure(error);\n if(globalThis.__XJET?.runtime.bail) {\n context.hasError = true;\n }\n } finally {\n inject(SuiteState).test = undefined;\n }\n }\n\n /**\n * Determines whether a test should be skipped due to errors in setup hooks.\n *\n * @param context - The test execution context containing shared state and potential setup errors\n * @returns Boolean indicating whether the test should be skipped\n *\n * @remarks\n * This method checks if any errors occurred in beforeAll hooks and reports them as test failures.\n * Tests are skipped when setup errors are present to prevent misleading test results.\n *\n * @see ContextInterface\n *\n * @internal\n *\n * @since 1.0.0\n */\n\n private shouldSkipDueToSetupErrors(context: ContextType<ContextInterface>): boolean {\n if (context.beforeAllErrors && context.beforeAllErrors.length > 0) {\n this.notifyTestFailure(context.beforeAllErrors as Array<unknown>);\n\n return true;\n }\n\n return false;\n }\n\n private determineSkipAction(isExclusiveMode: boolean): boolean {\n if(inject(SuiteState).isOnlyMode && !this.testOptions.only) {\n this.notifyTestStatus(true);\n\n return true;\n }\n\n if (this.testOptions.skip || this.testOptions.todo) {\n this.notifyTestStatus(this.testOptions.skip, this.testOptions.todo);\n\n return true;\n }\n\n if(isExclusiveMode && !this.testOptions.only) {\n this.notifyTestStatus(true);\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Executes a test with proper lifecycle hooks and timeout management.\n *\n * @param context - The test execution context containing shared state and utilities\n * @param runLifecycleHooks - Function that runs the specified hook type with the given context\n *\n * @returns Promise that resolves when the test and all its lifecycle hooks have completed\n *\n * @throws TimeoutError - When the test execution exceeds the configured timeout duration\n *\n * @remarks\n * This method orchestrates the complete test execution flow including:\n * 1. Running beforeEach hooks\n * 2. Executing the actual test body with timeout protection\n * 3. Running afterEach hooks regardless of test outcome\n *\n * @internal\n * @see HookType\n * @see ContextInterface\n * @see withTimeout\n *\n * @since 1.0.0\n */\n\n private async executeTestWithLifecycle(\n context: ContextType<ContextInterface>,\n runLifecycleHooks: FunctionLikeType<Promise<void>, [ HookType, ContextType<ContextInterface> ]>\n ): Promise<void> {\n await runLifecycleHooks(HookType.BEFORE_EACH, context);\n\n await withTimeout<void>(\n this.executeTestWithContext(context),\n this.timeoutDuration,\n `'${ this.timeoutDuration }' test`,\n this.executionLocation\n );\n\n await runLifecycleHooks(HookType.AFTER_EACH, context);\n }\n\n /**\n * Validates the test outcome, handling failing tests and notifying of success.\n *\n * @throws FailingError - When a test is marked as failing but successfully completes\n *\n * @remarks\n * This method implements special handling for tests marked with the 'failing' option.\n * For failing tests, it throws an error if the test unexpectedly succeeds.\n * For normal tests, it reports a successful test outcome.\n *\n * @internal\n * @see ActionType\n * @see FailingError\n *\n * @since 1.0.0\n */\n\n private validateTestOutcome(): void {\n if (this.testOptions.failing) {\n throw new FailingError(this.executionLocation!);\n }\n\n this.notifyTestAction();\n }\n\n /**\n * Determines if the test is using callback-style asynchronous execution.\n *\n * @returns Boolean indicating whether the test uses the callback pattern\n *\n * @remarks\n * This method analyzes the test implementation's parameter count to detect callback-style tests.\n * It identifies two callback patterns:\n * 1. A test function that expects exactly one parameter (the callback) with no test parameters\n * 2. A test function that expects exactly two parameters (test arguments and callback)\n *\n * The callback pattern is an alternative to Promise-based async tests.\n *\n * @internal\n * @since 1.0.0\n */\n\n private isCallbackStyle(): boolean {\n if (this.testImplementation.length === 1 && this.testParameters.length === 0)\n return true;\n\n // Or if it expects more parameters (test args + callback)\n return this.testImplementation.length === 2;\n }\n\n private getExecutionStrategy(): TestExecutionType {\n if (isPromise(this.testImplementation)) return TestExecutionType.ASYNC;\n if (this.isCallbackStyle()) return TestExecutionType.CALLBACK;\n\n return TestExecutionType.SYNC;\n }\n\n /**\n * Executes the test function with the appropriate execution strategy based on its type.\n *\n * @param context - The test execution context containing shared state and utilities\n *\n * @returns Promise that resolves when the test execution completes\n *\n * @throws Error - When the test execution fails for any reason\n *\n * @remarks\n * This method determines and applies the correct execution strategy for the test:\n * - For synchronous and async tests, it calls the test implementation directly with the context\n * - For callback-style tests, it delegates to a specialized execution method\n * The method ensures proper 'this' binding by using Function.prototype.apply\n *\n * @internal\n * @see ContextInterface\n * @see TestExecutionType\n *\n * @since 1.0.0\n */\n\n private async executeTestWithContext(context: ContextType<ContextInterface>): Promise<void> {\n const strategy = this.getExecutionStrategy();\n\n switch (strategy) {\n case TestExecutionType.ASYNC:\n case TestExecutionType.SYNC:\n await this.testImplementation.apply(context, this.testParameters);\n break;\n case TestExecutionType.CALLBACK:\n await this.executeCallbackStyleTest(context);\n break;\n }\n }\n\n /**\n * Executes a callback-style test by wrapping it in a Promise.\n *\n * @param context - The test execution context containing shared state and utilities\n *\n * @returns Promise that resolves when the callback is invoked without an error, or rejects when called with an error\n *\n * @throws Error - When the callback is invoked with an error parameter\n *\n * @remarks\n * This method adapts callback-style test functions to work within a Promise-based execution flow.\n * It creates a Promise wrapper around the test function and:\n * 1. Defines a callback function that resolves/rejects the Promise based on error parameter\n * 2. Appends this callback to the original test parameters\n * 3. Invokes the test with proper context binding using Function.prototype.apply\n *\n * The callback function follows Node.js convention with an optional error as first parameter.\n *\n * @internal\n * @see ContextInterface\n *\n * @since 1.0.0\n */\n\n private async executeCallbackStyleTest(context: ContextType<ContextInterface>): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const callbackFn = (error?: string | { message: string }): void => {\n if (error) reject(error);\n resolve();\n };\n\n const allParameters = [ ...this.testParameters ];\n allParameters.push(callbackFn);\n\n this.testImplementation.apply(context, allParameters);\n });\n }\n\n /**\n * Calculates the elapsed execution time of the test in milliseconds.\n *\n * @returns Number representing the test execution duration in milliseconds\n *\n * @remarks\n * This method computes the time difference between now and when the test started execution.\n * It returns 0 if the test has not yet started (when executionStartTime is 0).\n * The time measurement uses the system clock via Date.now().\n *\n * @internal\n * @since 1.0.0\n */\n\n private getExecutionDuration(): number {\n if (this.executionStartTime === 0) return 0;\n\n return Date.now() - this.executionStartTime;\n }\n\n\n private notifyTestStatus(skip: boolean = false, todo: boolean = false): void {\n emitStatus(MessageType.Test, {\n todo: todo,\n skipped: skip,\n ancestry: this.ancestry,\n description: this.description\n });\n }\n\n /**\n * Emits an action event when a test execution has a significant state change.\n *\n * @param type - The type of action event to emit (e.g., start, complete, skip)\n * @param errors - Collection of errors that occurred during test execution\n *\n * @remarks\n * This method broadcasts notifications about test execution actions through the event system.\n * It includes comprehensive information about the test:\n * - Any errors that occurred\n * - Test type as a KindType\n * - The test's ancestry (parent hierarchy)\n * - Execution duration up to the point of notification\n * - Source code location information\n * - The test's description text\n * These action events are typically consumed by reporters and test runners.\n *\n * @internal\n * @see KindType\n * @see EmitActionEventType\n *\n * @since 1.0.0\n */\n\n private notifyTestAction(errors: Array<unknown> = []): void {\n emitEvent(MessageType.Test, {\n errors: <Array<Error>> errors,\n ancestry: this.ancestry,\n duration: this.getExecutionDuration(),\n description: this.description\n });\n }\n\n /**\n * Emits a test failure action event with the associated error information.\n *\n * @param error - The error or errors that caused the test to fail\n *\n * @remarks\n * This method standardizes the reporting of test failures by:\n * 1. Ensuring errors are always passed as an array\n * 2. Converting single errors to array format when needed\n * 3. Delegating to the more general notifyTestAction method with the FAILURE action type\n * It serves as a specialized wrapper around the general action notification system.\n *\n * @internal\n * @see ActionType\n *\n * @since 1.0.0\n */\n\n private notifyTestFailure(error: unknown): void {\n this.notifyTestAction(Array.isArray(error) ? error : [ error ]);\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { TestFlagsType } from '@shared/models/interfaces/test-model.interface';\nimport type { TestCallbackType, TestDirectiveInterface } from '@shared/directives/interfaces/test-directive.interface';\n\n/**\n * Imports\n */\n\nimport { each } from './each.directive';\nimport { TestModel } from '@shared/models/test.model';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { getTrimmedStackString } from '@components/location.component';\n\n/**\n * Implementation of the test directive that allows for test definition with chainable modifiers.\n * Acts as a function that can be invoked directly while also providing chainable property access.\n *\n * @template T - Type parameter for the test callback return type\n *\n * @param description - The test description\n * @param block - The test implementation function\n * @param timeout - Optional timeout in milliseconds\n *\n * @returns void\n *\n * @throws Error - When attempting to nest tests inside other tests\n * @throws Error - When using incompatible flag combinations (e.g., skip with only)\n *\n * @remarks\n * This class extends Function to allow it to be invoked as a function while also\n * providing methods and properties. It uses a Proxy to capture function invocations\n * and redirects them to the invoke method.\n *\n * @example\n * ```ts\n * // Basic test\n * test('should work', () => {\n * expect(2 + 2).toBe(4);\n * });\n *\n * // With modifiers\n * test.only('runs exclusively', () => {\n * expect(true).toBe(true);\n * });\n *\n * // Parameterized tests\n * test.each([1, 2, 3])('test with value %s', (value) => {\n * expect(typeof value).toBe('number');\n * });\n * ```\n *\n * @see SuiteState\n * @see TestDirectiveInterface\n *\n * @since 1.0.0\n */\n\nexport class TestDirective extends Function {\n /**\n * Singleton instance of the TestDirective class.\n *\n * @see TestDirectiveInterface\n * @since 1.0.0\n */\n\n private static instance?: TestDirective;\n\n /**\n * Error messages for invalid flag combinations in test configuration.\n *\n * @since 1.0.0\n */\n\n private static readonly ERROR_MESSAGES = {\n SKIP_ONLY: 'Cannot use \"only\" flag on skipped test',\n ONLY_SKIP: 'Cannot use \"skip\" flag on only test',\n SKIP_TODO: 'Cannot use \"todo\" flag on skipped test',\n SKIP_FAILING: 'Cannot use \"failing\" flag on skipped test'\n };\n\n /**\n * Default timeout in milliseconds for test execution\n * @since 1.0.0\n */\n\n private static readonly DEFAULT_TIMEOUT = globalThis.__XJET?.runtime.timeout ?? 5000;\n\n /**\n * Configuration options controlling test behavior\n\n * @see TestFlagsType\n * @since 1.0.0\n */\n\n private options: TestFlagsType = {};\n\n /**\n * @param invokationStack - The precise source code invocationStack where the error occurred\n */\n\n private invocationStack: string = '';\n\n /**\n * Private constructor that initializes the TestDirective instance and returns a proxied version.\n *\n * @returns A Proxy that handles direct function invocation by redirecting to the invoke method\n *\n * @remarks\n * The constructor is private to enforce the singleton pattern. It creates a Proxy\n * that allows the object to be called as a function while maintaining its object properties.\n * When called as a function, the proxy redirects the call to the invoke method.\n *\n * @internal\n * @see invoke\n *\n * @since 1.0.0\n */\n\n private constructor() {\n super();\n\n return new Proxy(this, {\n apply: (target, _, args: [string, FunctionType, number?]): void => {\n const [ description, block, timeout ] = args;\n this.invocationStack = getTrimmedStackString(2);\n\n target.invoke(description, block, [], timeout);\n }\n });\n }\n\n /**\n * Returns the singleton instance of TestDirective, creating it if it doesn't exist\n *\n * @returns The singleton instance of the test directive implementation\n *\n * @remarks\n * This method implements the singleton pattern, ensuring only one instance of the test directive exists\n * throughout the application lifecycle\n *\n * @example\n * ```ts\n * const test = TestDirective.getInstance();\n * test('my test', () => {\n * // test implementation\n * });\n * ```\n *\n * @see TestDirectiveInterface\n *\n * @since 1.0.0\n */\n\n static getInstance(): TestDirectiveInterface {\n if (!TestDirective.instance) {\n TestDirective.instance = new TestDirective();\n }\n\n return TestDirective.instance as unknown as TestDirectiveInterface;\n }\n\n /**\n * Returns the singleton instance of TestDirective, creating it if it doesn't exist.\n *\n * @returns The singleton instance of TestDirective cast to TestDirectiveInterface\n *\n * @remarks\n * This method implements the Singleton pattern to ensure only one instance of\n * TestDirective exists in the application. It creates the instance on the first call\n * and returns the existing instance on subsequent calls.\n *\n * @example\n * ```ts\n * const test = TestDirective.getInstance();\n * test('example test', () => {\n * expect(true).toBe(true);\n * });\n * ```\n *\n * @since 1.0.0\n */\n\n get skip(): this {\n if (this.options.only) throw new Error(TestDirective.ERROR_MESSAGES.ONLY_SKIP);\n this.options.skip = true;\n\n return this;\n }\n\n /**\n * Sets the 'only' flag for this test, making it the only test to run in its suite.\n *\n * @returns This instance with the 'only' flag set\n *\n * @throws Error - When attempting to set 'only' flag on a skipped test\n *\n * @example\n * ```ts\n * test.only('this is the only test that will run', () => {\n * expect(true).toBe(true);\n * });\n * ```\n *\n * @see skip\n * @since 1.0.0\n */\n\n get only(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_ONLY);\n this.options.only = true;\n\n return this;\n }\n\n /**\n * Marks a test as a todo item, indicating it's planned but not yet implemented\n *\n * @throws Error - When attempting to use todo flag on a skipped test\n *\n * @remarks\n * Todo tests appear in test reports to remind developers of planned work,\n * but don't execute any test code\n *\n * @example\n * ```ts\n * // Define a todo test\n * test.todo('feature that needs implementation');\n * ```\n *\n * @see TestFlagsType\n *\n * @since 1.0.0\n */\n\n get todo(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_TODO);\n this.options.todo = true;\n\n return this;\n }\n\n /**\n * Marks the test as expected to fail.\n *\n * @returns This instance with the 'failing' flag set\n *\n * @throws Error - When attempting to mark a skipped test as failing\n *\n * @example\n * ```ts\n * test.failing('this test is expected to fail', () => {\n * throw new Error('This is an expected failure');\n * });\n * ```\n *\n * @see skip\n * @since 1.0.0\n */\n\n get failing(): this {\n if (this.options.skip) throw new Error(TestDirective.ERROR_MESSAGES.SKIP_FAILING);\n this.options.failing = true;\n\n return this;\n }\n\n /**\n * Creates a parameterized test using template strings.\n *\n * @template T - Array type containing the values to be used in the test\n *\n * @param string - Template string array used to create the test title\n * @param placeholders - Values to be inserted into the template string\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each`\n * a | b | expected\n * ${1} | ${1} | ${2}\n * ${2} | ${2} | ${4}\n * `('returns $expected when $a is added to $b', ({a, b, expected}) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each.array\n * @since 1.0.0\n */\n\n each<T extends ReadonlyArray<unknown>>(string: TemplateStringsArray, ...placeholders: T): TestCallbackType<Record<string, T[number]>>;\n\n /**\n * Creates a parameterized test using arrays of test cases.\n *\n * @template T - Type representing the test case data structure\n *\n * @param cases - Arrays containing test case values\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T extends Array<unknown> | [unknown]>(...cases: T[]): TestCallbackType<T>; // array\n\n /**\n * Creates a parameterized test using individual test case objects or primitive values.\n *\n * @template T - Type representing the test case data\n *\n * @param args - Test case objects or primitive values\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * { a: 1, b: 1, expected: 2 },\n * { a: 1, b: 2, expected: 3 },\n * { a: 2, b: 2, expected: 4 }\n * )('adds $a + $b to equal $expected', ({ a, b, expected }) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T>(...args: readonly T[]): TestCallbackType<T>; // object, and primitives\n\n /**\n * Creates a parameterized test using arrays of primitive values as test cases.\n *\n * @template T - Array type containing the primitive test values\n *\n * @param args - Arrays of primitive values to be used as test cases\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 2, 3],\n * [4, 5, 9],\n * [6, 7, 13]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each\n * @since 1.0.0\n */\n\n each<T extends Array<unknown>>(...args: T): TestCallbackType<T[number]>; // primitives\n\n /**\n * Creates a parameterized test using various input formats.\n *\n * @param args - Test case data in array format\n * @returns A callback function for creating the parameterized test\n *\n * @remarks\n * This method delegates to the implementation after binding the invoke method to the current context.\n *\n * The description supports parameter formatting with the following placeholders:\n * - %p - pretty-format output\n * - %s - String value\n * - %d, %i - Number as integer\n * - %f - Floating point value\n * - %j - JSON string\n * - %o - Object representation\n * - %# - Index of the test case\n * - %% - Single percent sign (doesn't consume an argument)\n *\n * Alternatively, you can inject object properties using $variable notation:\n * - $variable - Injects the property value\n * - $variable.path.to.value - Injects nested property values (works only with own properties)\n * - $# - Injects the index of the test case\n * - Note: $variable cannot be combined with printf formatting except for %%\n *\n * @example\n * ```ts\n * test.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('adds %i + %i to equal %i', (a, b, expected) => {\n * expect(a + b).toBe(expected);\n * });\n * ```\n *\n * @see each.table\n * @see each.array\n * @since 1.0.0\n */\n\n each(...args: Array<unknown>): TestCallbackType<unknown> {\n return each(this.invoke.bind(this), ...args);\n }\n\n /**\n * Invokes a test with the provided description, test function, arguments, and optional timeout.\n *\n * @param description - The description of the test to be displayed in test reports\n * @param block - The test function containing the test logic\n * @param args - Additional arguments to be passed to the test function\n * @param timeout - Optional timeout value in milliseconds for the test\n *\n * @throws TestNestingError - When attempting to create a nested test\n *\n * @remarks\n * This method handles the complete test registration flow, including validation,\n * creation, registration, and flag management. If no test function is provided,\n * the test will be automatically marked as todo.\n *\n * @example\n * ```ts\n * invoke('should sum two numbers', (a, b) => {\n * expect(sum(a, b)).toBe(a + b);\n * }, [5, 10], 2000);\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n invoke(description: string, block: FunctionType, args: Array<unknown> = [], timeout?: number): void {\n this.validateTestNesting(description);\n\n // Auto-set todo flag if no test function provided\n if (!block) {\n this.options.todo = true;\n }\n\n // Create and register the test\n const test = this.createTest(description, block, args, timeout);\n this.registerTest(test, this.invocationStack);\n\n // Reset options after test creation\n this.resetFlags();\n }\n\n /**\n * Validates that tests are not being nested inside other tests.\n *\n * @param description - The description of the test being validated\n *\n * @throws Error - When a test is nested inside another test, with details about both tests\n *\n * @remarks\n * Nesting tests is not supported in the testing framework as it can lead to unpredictable behavior\n * and difficult-to-debug test scenarios.\n *\n * @internal\n * @since 1.0.0\n */\n\n private validateTestNesting(description: string): void {\n const runningTest = inject(SuiteState).test;\n if (runningTest) {\n // set invokation\n throw new Error(`Cannot nest a test inside a test '${ description }' in '${ runningTest.description }'`);\n }\n }\n\n /**\n * Creates a new TestModel with the current configuration\n */\n private createTest(description: string, block: FunctionType, args: Array<unknown>, timeout?: number): TestModel {\n return new TestModel(\n description,\n block,\n timeout ?? TestDirective.DEFAULT_TIMEOUT,\n args,\n { ...this.options } // Clone options to prevent shared references\n );\n }\n\n /**\n * Registers a test with the test suite and sets its execution invocationStack.\n *\n * @param test - The test model to register\n * @param location - The precise source code invocationStack where the error occurred\n *\n * @remarks\n * This method determines the invocationStack where the test was invoked in the source code\n * and attaches that information to the test before adding it to the suite state.\n * Location information is useful for error reporting and test navigation.\n *\n * @internal\n * @since 1.0.0\n */\n\n private registerTest(test: TestModel, location: string): void {\n if (location) {\n test.setExecutionLocation(location);\n }\n inject(SuiteState).addTest(test);\n }\n\n /**\n * Resets all test configuration options to their default state.\n *\n * @returns Nothing\n *\n * @remarks\n * This method clears all previously set options to ensure that configuration\n * from one test doesn't leak into subsequent tests.\n *\n * @internal\n * @since 1.0.0\n */\n\n private resetFlags(): void {\n this.options = {};\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\nimport type { DescribeOptionsInterface } from '@shared/models/interfaces/describe-model.interface';\nimport type { DescribeCallbackType } from '@shared/directives/interfaces/describe-directive.interface';\nimport type { DescribeDirectiveInterface } from '@shared/directives/interfaces/describe-directive.interface';\n\n/**\n * Imports\n */\n\nimport { SuiteState } from '@shared/states/suite.state';\nimport { each } from '@shared/directives/each.directive';\nimport { inject } from '@symlinks/services/inject.service';\n\n/**\n * Implementation of the describe directive that allows for test suite definition with chainable modifiers.\n * Acts as a function that can be invoked directly while also providing chainable property access.\n *\n * @param description - The test suite description\n * @param block - The test suite implementation function\n *\n * @throws Error - When attempting to nest describe blocks inside tests\n * @throws Error - When using incompatible flag combinations (e.g., skip with only)\n *\n * @remarks\n * This class extends Function to allow it to be invoked as a function while also\n * providing methods and properties. It uses a Proxy to capture function invocations\n * and redirects them to the invoke method.\n *\n * The describe directive creates a group of related tests, providing organization and structure\n * to test suites. It supports chainable modifiers for customizing test suite behavior,\n * and parameterized testing via the 'each' method.\n *\n * @example\n * ```ts\n * // Basic describe block\n * describe('Calculator', () => {\n * test('should add numbers', () => {\n * expect(2 + 2).toBe(4);\n * });\n * });\n *\n * // With modifiers\n * describe.only('Priority feature', () => {\n * test('important test case', () => {\n * expect(true).toBe(true);\n * });\n * });\n *\n * // With parameterized tests using each\n * describe.each([1, 2, 3])('Math operations for %s', (value) => {\n * test('square', () => {\n * expect(value * value).toBeGreaterThan(0);\n * });\n * });\n * ```\n *\n * @see SuiteState\n * @see DescribeDirectiveInterface\n *\n * @since 1.0.0\n */\n\nexport class DescribeDirective extends Function {\n /**\n * Singleton instance of the DescribeDirective class.\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n private static instance: DescribeDirectiveInterface | null = null;\n\n /**\n * Configuration options controlling test suite behavior\n *\n * @see DescribeOptionsInterface\n * @since 1.0.0\n */\n\n private options: DescribeOptionsInterface = {};\n\n /**\n * Private constructor that initializes the DescribeDirective instance and returns a proxied version.\n *\n * @returns A Proxy that handles direct function invocation by redirecting to the invoke method\n *\n * @remarks\n * The constructor is private to enforce the singleton pattern. It creates a Proxy\n * that allows the object to be called as a function while maintaining its object properties.\n * When called as a function, the proxy redirects the call to the invoke method.\n *\n * @internal\n * @see invoke\n *\n * @since 1.0.0\n */\n\n private constructor() {\n super();\n\n return <this>new Proxy(this, {\n apply(target, thisArg, args: [ string, FunctionType ]): void {\n target.invoke(args[0], args[1]);\n }\n });\n }\n\n /**\n * Returns the singleton instance of DescribeDirective, creating it if it doesn't exist\n *\n * @returns The singleton instance of the describe directive implementation\n *\n * @remarks\n * This method implements the singleton pattern, ensuring only one instance of the describe directive\n * exists throughout the application lifecycle.\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n static getInstance(): DescribeDirectiveInterface {\n if (!DescribeDirective.instance) {\n DescribeDirective.instance = <DescribeDirectiveInterface><unknown>new DescribeDirective();\n }\n\n return DescribeDirective.instance;\n }\n\n /**\n * Creates a skipped test suite that will be recognized but not executed during test runs\n *\n * @returns The same DescribeDirective instance with skip flag enabled, allowing for method chaining\n * @throws Error - When attempting to combine with 'only' flag which would create conflicting behavior\n *\n * @remarks\n * When applied, the test suite will be marked as skipped in test reports but won't be executed.\n * Cannot be combined with the 'only' modifier due to conflicting behavior.\n *\n * @example\n * ```ts\n * describe.skip('temporarily disabled suite', () => {\n * test('will not run', () => {\n * expect(result).toBe(true);\n * });\n * });\n * ```\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n get skip(): this {\n if (this.options.only) throw new Error('Cannot use \"skip\" flag on only test');\n this.options.skip = true;\n\n return this;\n }\n\n /**\n * Creates an exclusive test suite that will run while other non-exclusive suites are skipped\n *\n * @returns The same DescribeDirective instance with only flag enabled, allowing for method chaining\n * @throws Error - When attempting to combine with 'skip' flag which would create conflicting behavior\n *\n * @remarks\n * When applied, only this test suite and other suites marked with 'only' will be executed.\n * This is useful for focusing on specific test suites during development or debugging.\n * Cannot be combined with the 'skip' modifier due to conflicting behavior.\n *\n * @example\n * ```ts\n * describe.only('focus on this suite', () => {\n * test('will run', () => {\n * expect(result).toBe(expectedValue);\n * });\n * });\n * ```\n *\n * @see DescribeDirectiveInterface\n * @since 1.0.0\n */\n\n get only(): this {\n if (this.options.skip) throw new Error('Cannot use \"only\" flag on skipped test');\n this.options.only = true;\n\n return this;\n }\n\n /**\n * Generates parameterized test suites from template strings and placeholders.\n *\n * @template T - An array type extending ReadonlyArray<unknown> that contains the placeholder values\n *\n * @param string - A template string array that defines the structure of test suite descriptions\n * @param placeholders - Values to be inserted into the template strings to create test suites\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the number of placeholders doesn't match the template string requirements\n *\n * @remarks\n * This method uses tagged template literals to create parameterized test suites.\n * The values provided as placeholders will be passed to describe callbacks as named parameters.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the parameters in each row as function arguments.\n * - timeout (optional): Number - Time in milliseconds to wait for each row before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each`\n * a | b | expected\n * ${1} | ${1} | ${2}\n * ${1} | ${2} | ${3}\n * ${2} | ${2} | ${4}\n * `('addition: $a + $b = $expected', ({a, b, expected}) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends ReadonlyArray<unknown>>(string: TemplateStringsArray, ...placeholders: T): DescribeCallbackType<Record<string, T[number]>>;\n\n /**\n * Creates parameterized test suites from arrays of test case values.\n *\n * @template T - A type extending Array<unknown> or [unknown] that contains the test case values\n *\n * @param cases - Arrays of values representing individual test cases\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the test cases have inconsistent formats or types\n *\n * @remarks\n * This method allows creating parameterized test suites from arrays of values.\n * Each array provided as a case will be passed to the describe callback as separate arguments.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the parameters in each row as function arguments.\n * - timeout (optional): Number - Time in milliseconds to wait for each row before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * [1, 1, 2],\n * [1, 2, 3],\n * [2, 2, 4]\n * )('addition: %d + %d = %d', (a, b, expected) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends Array<unknown> | [ unknown ]>(...cases: T[]): DescribeCallbackType<T>; // array\n\n /**\n * Creates parameterized test suites from individual test case values.\n *\n * @template T - The type of test case values (objects or primitives)\n *\n * @param args - Individual test case values to be used in the test suites\n *\n * @returns A callback function compatible with Jest's describe method that provides parameterized test data\n *\n * @throws TypeError - When the test cases have incompatible types\n *\n * @remarks\n * This method allows creating parameterized test suites from individual values.\n * Each value provided as an argument will be passed to the describe callback.\n * This overload is particularly useful for objects and primitive values.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the test case value as an argument.\n * - timeout (optional): Number - Time in milliseconds to wait for each test case before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * { a: 1, b: 1, expected: 2 },\n * { a: 1, b: 2, expected: 3 },\n * { a: 2, b: 2, expected: 4 }\n * )('addition: $a + $b = $expected', ({ a, b, expected }) => {\n * test('equals expected value', () => {\n * expect(a + b).toBe(expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T>(...args: readonly T[]): DescribeCallbackType<T>; // object, and primitives\n\n /**\n * Creates parameterized test suites from individual objects or primitive values.\n *\n * @template T - The type of test case values\n *\n * @param args - Individual objects or primitive values to be used as test cases\n *\n * @returns A callback function compatible with Jest's describe method\n *\n * @remarks\n * This method creates parameterized test suites where each argument represents a complete test case.\n * Useful for testing with objects or primitive values that each represent a single test scenario.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block.\n * Generate unique describe titles by positionally injecting parameters with printf formatting:\n * %p - pretty-format.\n * %s - String.\n * %d - Number.\n * %i - Integer.\n * %f - Floating point value.\n * %j - JSON.\n * %o - Object.\n * %# - Index of the test suite.\n * %% - single percent sign ('%'). This does not consume an argument.\n * Or generate unique describe titles by injecting properties of test suite object with $variable:\n * - To inject nested object values use a keyPath i.e. $variable.path.to.value (only works for \"own\" properties)\n * - You can use $# to inject the index of the test suite\n * - You cannot use $variable with the printf formatting except for %%\n * - fn: Function - The describe callback to be run, this is the function that will receive the test case value as an argument.\n * - timeout (optional): Number - Time in milliseconds to wait for each test case before aborting. Default is 5 seconds.\n *\n * @example\n * ```ts\n * describe.each(\n * { input: 'hello', expected: 'HELLO' },\n * { input: 'world', expected: 'WORLD' }\n * )('toUpperCase($input) \u2192 $expected', (testCase) => {\n * test('converts correctly', () => {\n * expect(testCase.input.toUpperCase()).toBe(testCase.expected);\n * });\n * });\n * ```\n *\n * @see DescribeCallbackType\n * @since 1.0.0\n */\n\n each<T extends Array<unknown>>(...args: T): DescribeCallbackType<T[number]>; // primitives\n\n /**\n * Creates parameterized test suites by delegating to the external 'each' function.\n *\n * @param args - Test case values to be used in the parameterized test suites\n *\n * @returns A callback function compatible with Jest's describe method\n *\n * @remarks\n * This method serves as a bridge between the describe context and the external 'each' utility.\n * It binds the current context's 'invoke' method and passes it along with the test cases\n * to the external 'each' function, which handles the creation of parameterized test suites.\n *\n * The returned function has the same behavior as the one returned by the external 'each' function,\n * but ensures that tests are executed within the proper describe context.\n *\n * The returned function accepts the following parameters:\n * - name: String - The title of the describe block, which can include parameter placeholders\n * - fn: Function - The describe callback function that will receive the test case values\n * - timeout (optional): Number - Time in milliseconds before test timeout\n *\n * @example\n * ```ts\n * // Internal implementation used when calling describe.each\n * // Users don't directly call this method, but rather use:\n * describe.each([1, 2, 3])('test with %d', (num) => {\n * test('works with ' + num, () => {\n * expect(num).toBeDefined();\n * });\n * });\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n each(...args: Array<unknown>): DescribeCallbackType<unknown> {\n return each(this.invoke.bind(this), ...args);\n }\n\n /**\n * Executes a describe block with the given description and function.\n *\n * @param description - The title of the describe block\n * @param block - The function containing the tests to be run within this describe block\n * @param args - Optional array of arguments to pass to the block function\n *\n * @throws Error - When attempting to nest a describe block inside a test\n *\n * @remarks\n * This method is the core implementation for creating test suites in the testing framework.\n * It registers a describe block with the suite state manager and applies any options\n * that were set on the describe object before this method was called.\n *\n * This method is primarily called internally by the testing framework and\n * typically not meant to be called directly by users.\n *\n * @example\n * ```ts\n * // Internal implementation example - not for direct use\n * const describeObj = new Describe();\n * describeObj.invoke('My test suite', () => {\n * // Test implementations\n * });\n * ```\n *\n * @internal\n * @since 1.0.0\n */\n\n invoke(description: string, block: FunctionType, args: Array<unknown> = []): void {\n const suiteState = inject(SuiteState);\n const runningTest = suiteState.test;\n\n if (runningTest) {\n throw new Error(\n `Cannot nest a describe inside a test '${ description }' in '${ runningTest.description }'`\n );\n }\n\n suiteState.addDescribe(description, block, this.options, args);\n // Reset options after use\n this.options = {};\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { ContextType, FunctionType } from '@remotex-labs/xjet-expect';\nimport type { CallbackHandlerType } from '@shared/models/interfaces/hook-model.interface';\n\n\n/**\n * Imports\n */\n\nimport { isPromise } from '@remotex-labs/xjet-expect';\nimport { withTimeout } from '@components/timeout.component';\n\n/**\n * Represents a model for managing and executing hook functions with a specified timeout.\n * Provides functionality for associating invocation locations and handling errors during execution.\n *\n * @remarks\n * This class ensures that hooks are executed with proper timeout enforcement\n * and supports both synchronous and asynchronous hook functions.\n * It throws an error if an asynchronous hook\n * incorrectly uses a \"done\" callback or if it fails to complete execution within the specified timeout.\n *\n * @since 1.0.0\n */\n\nexport class HookModel {\n /**\n * Represents the current location of an invocation within the application or a fallback to undefined.\n *\n * @remarks\n * This variable is designed\n * to hold the interface representing the invocation's location for tracking.\n * If no invocation location is available, it defaults to undefined.\n *\n * @since 1.0.0\n */\n\n private location: string = '';\n\n /**\n * Constructs an instance of the class.\n *\n * @param hookFunction - The callback function that will be executed based on specific conditions.\n * @param timeout - The time in milliseconds before the callback function is triggered.\n * @throws Will throw an error if the provided timeout value is negative or invalid.\n *\n * @remarks This constructor sets up the necessary callback function and timeout configuration for the instance.\n *\n * @since 1.0.0\n */\n\n constructor(\n private readonly hookFunction: CallbackHandlerType, private readonly timeout: number\n ) {}\n\n /**\n * Sets the location of the invocation based on the provided location object.\n *\n * @param location - An object implementing the `InvocationLocationType` or `undefined`\n * to reset the location.\n *\n * @remarks\n * This method assigns a new location value to the current location of the invocation.\n * Passing `undefined` will clear the current location.\n *\n * @since 1.0.0\n */\n\n setLocation(location: string): void {\n this.location = location;\n }\n\n /**\n * Executes a hook function with a timeout mechanism.\n *\n * @param context - The context object passed to the hook function, containing execution-specific information.\n * @return A promise that resolves when the hook function completes its execution successfully.\n *\n * @throws TimeoutError - If the hook function does not call `done()` within the specified timeout duration.\n *\n * @remarks This method concurrently runs the hook function and a timeout check, ensuring that execution does not\n * exceed the predefined timeout.\n * If the timeout is reached without the hook function completing, an ` TimeoutError ` is thrown.\n *\n * @since 1.0.0\n */\n\n async run(context: ContextType<unknown>): Promise<void> {\n return withTimeout<void>(\n this.executeHook(this.hookFunction, context),\n this.timeout,\n 'hook while waiting for \\'done()\\' to be called.',\n this.location\n );\n }\n\n /**\n * Executes a given hook function, handling both synchronous and asynchronous hooks,\n * with or without a callback mechanism.\n *\n * @param hook - The function representing the hook to be executed.\n * It Can be a synchronous or asynchronous function.\n * @param context - An object to be used as the `this` context\n * when invoking the hook function.\n\n * @remarks This method ensures correct execution and error handling\n * for both callback-based and promise-based hooks.\n *\n * @since 1.0.0\n */\n\n private async executeHook(hook: FunctionType, context: unknown): Promise<void> {\n if (isPromise(hook) && hook.length > 0) {\n throw new Error(`Async hook '${ hook.name }' should not use 'done' callback.`);\n }\n\n if (hook.length > 0) {\n return this.executeCallbackHook(hook, context);\n }\n\n return hook.call(context);\n }\n\n /**\n * Executes a callback-style hook by wrapping it in a Promise\n *\n * @param hook - The callback hook function to execute\n * @param context - Execution context to bind to the hook function\n * @returns A Promise that resolves when the hook completes or rejects when it fails\n *\n * @throws Error - When the hook callback is invoked with an error parameter\n *\n * @remarks This method converts traditional Node.js-style callback patterns (error-first callbacks)\n * into Promise-based async/await compatible functions. The hook function receives a done callback\n * as its argument and must call it to signal completion.\n *\n * @example\n * ```ts\n * const callbackHook = (done) => {\n * setTimeout(() => done(), 100);\n * };\n *\n * await executeCallbackHook(callbackHook, this);\n * ```\n *\n * @see isPromise\n * @since 1.0.0\n */\n\n private executeCallbackHook(hook: FunctionType, context: unknown): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n hook.call(context, (error?: string | { message: string }): void => {\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n }\n}\n", "/**\n * Import will remove at compile time\n */\n\nimport type { FunctionType } from '@remotex-labs/xjet-expect';\n\n/**\n * Imports\n */\n\nimport { HookModel } from '@shared/models/hook.model';\nimport { SuiteState } from '@shared/states/suite.state';\nimport { inject } from '@symlinks/services/inject.service';\nimport { getTrimmedStackString } from '@components/location.component';\nimport { HookType } from '@shared/models/constants/hook.model.constants';\n\n/**\n * Default timeout\n */\n\nconst DEFAULT_TIMEOUT = globalThis.__XJET?.runtime.timeout ?? 5000;\n\n/**\n * Creates and registers a hook with the current test suite\n *\n * @param hookType - Type of hook to register\n * @param callback - Function to execute for this hook\n * @param location - The precise source code location where the error occurred\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @example\n * ```ts\n * createHook(HookType.BEFORE_EACH, () => {\n * // Setup code to run before each test\n * resetTestDatabase();\n * }, 10000);\n * ```\n *\n * @see HookType\n * @see HookModel\n * @see SuiteState\n *\n * @since 1.0.0\n */\n\nexport function createHook(hookType: HookType, callback: FunctionType, location: string, timeout: number = DEFAULT_TIMEOUT): void {\n const hook = new HookModel(callback, timeout);\n hook.setLocation(location);\n inject(SuiteState).describe.addHook(hookType, hook);\n}\n\n/**\n * Registers an after-all hook to be executed once after all tests in a suite have completed\n *\n * @param callback - Function to execute after all tests in the suite\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating AFTER_ALL hooks.\n * After-all hooks are useful for cleanup operations that should occur once after all tests complete.\n *\n * @example\n * ```ts\n * afterAllDirective(() => {\n * // Teardown code to run after all tests\n * disconnectFromDatabase();\n * }, 10000);\n * ```\n *\n * @see createHook\n * @see HookType.AFTER_ALL\n *\n * @since 1.0.0\n */\n\nexport function afterAllDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.AFTER_ALL, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers a before-all hook to be executed once before any tests in a suite run\n *\n * @param callback - Function to execute before any tests in the suite\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating BEFORE_ALL hooks.\n * Before-all hooks are useful for setup operations that should occur once before any tests run.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * beforeAllDirective(() => {\n * // Setup code to run before any tests\n * initializeTestDatabase();\n * }, 10000);\n * ```\n *\n * @see createHook\n * @see HookType.BEFORE_ALL\n *\n * @since 1.0.0\n */\n\nexport function beforeAllDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.BEFORE_ALL, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers an after-each hook to be executed after each test in a suite completes\n *\n * @param callback - Function to execute after each test\n * @param timeout - Maximum execution time in milliseconds\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating AFTER_EACH hooks.\n * After-each hooks run after each test case and are useful for cleanup operations that should occur\n * after every individual test.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * afterEachDirective(() => {\n * // Cleanup code to run after each test\n * resetTestState();\n * }, 8000);\n * ```\n *\n * @see createHook\n * @see HookType.AFTER_EACH\n *\n * @since 1.0.0\n */\n\nexport function afterEachDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.AFTER_EACH, callback, getTrimmedStackString(), timeout);\n}\n\n/**\n * Registers a before-each hook to be executed before each test in a suite runs\n *\n * @param callback - Function to execute before each test\n * @param timeout - Maximum execution time in milliseconds\n *\n * @returns void\n *\n * @throws Error - If called outside a test suite context\n *\n * @remarks\n * This function is a wrapper around the createHook function, specifically for creating BEFORE_EACH hooks.\n * Before-each hooks run before each test case and are useful for setup operations that should occur\n * before every individual test.\n *\n * @default timeout 5000\n *\n * @example\n * ```ts\n * beforeEachDirective(() => {\n * // Setup code to run before each test\n * prepareTestEnvironment();\n * }, 8000);\n * ```\n *\n * @see createHook\n * @see HookType.BEFORE_EACH\n *\n * @since 1.0.0\n */\n\nexport function beforeEachDirective(callback: FunctionType, timeout?: number): void {\n createHook(HookType.BEFORE_EACH, callback, getTrimmedStackString(), timeout); // Fixed a bug here - was using AFTER_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,MAAM,OAAO,IAAI,EAGtC,SAAS,MAAM,EAAE,CACrB,CAAC,CACL,CATS,gCAeT,IAAM,aAAe,WAAY,CAC7B,IAAM,QAAU,WAEhB,QAAQ,KAAO,CAKX,GAAI,iBACJ,KAAM,mBACN,MAAO,oBACP,cAAe,WAAY,WAAW,WAAW,EAAlC,iBACf,cAAe,WAAY,WAAW,WAAW,EAAlC,iBACf,gBAAiB,WAAY,WAAW,aAAa,EAApC,mBAMjB,IACA,KACA,KACA,MACA,MAMA,aACA,cACA,cACA,eACA,kBACA,oBACA,qBACA,yBACJ,EAEA,QAAQ,OAAS,QACjB,QAAQ,MAAQ,OAAO,UAAU,EACjC,QAAQ,GAAK,cAAc,YAAY,EACvC,QAAQ,KAAO,cAAc,YAAY,EACzC,QAAQ,SAAW,kBAAkB,YAAY,EACjD,QAAQ,SAAW,kBACnB,QAAQ,UAAY,mBACpB,QAAQ,UAAY,mBACpB,QAAQ,WAAa,mBACzB,EAhDqB,gBAkDrB,aAAa",
7
+ "names": ["error", "serializeError", "error", "error", "serializeError", "LogLevel", "error", "mock", "_init", "error", "isPromise", "isPromise", "error"]
8
8
  }