Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:DevExpress Testcafe TestRunTracker

From Leeroopedia
Revision as of 11:13, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/DevExpress_Testcafe_TestRunTracker.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Async_Context, Test_Execution
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete utility that tracks the association between asynchronous execution contexts and their corresponding test runs, enabling TestCafe to resolve which test run is active when user code calls API methods.

Description

TestRunTracker uses Node.js async_hooks to track the relationship between async operations and test runs. When a test function executes, the tracker registers the current async context ID with the test run. Any subsequent async operations (callbacks, promises, timers) inherit this context. This allows methods like t.click() to automatically find the correct test run even when called from deeply nested async callbacks without explicit parameter passing.

Usage

This is a core infrastructure component that enables the t proxy to work. It runs automatically and is not called directly by test authors.

Code Reference

Source Location

Signature

class TestRunTracker {
    private _contextToTestRunMap: Map<number, TestRun>;
    private _hook: AsyncHook;

    public enabled: boolean;

    public addTrackingMarkerToFunction (testRunId: string, fn: Function): Function;
    public resolveContextTestRun (): TestRun | null;
    public getContextTestRunId (): string | null;
    public ensureEnabled (): void;
}

export default new TestRunTracker();

Import

import testRunTracker from '../api/test-run-tracker';

I/O Contract

Inputs

Name Type Required Description
testRunId string Yes ID of the test run to associate with the async context
fn Function Yes Function to mark with the test run context

Outputs

Name Type Description
resolveContextTestRun() TestRun or null The test run associated with the current async context
Wrapped function Function Function with injected test run tracking

Usage Examples

import testRunTracker from '../api/test-run-tracker';

// Internal: mark a test function with its test run context
const wrappedFn = testRunTracker.addTrackingMarkerToFunction(testRunId, userTestFn);

// Internal: resolve the current test run from any async context
const testRun = testRunTracker.resolveContextTestRun();
if (testRun)
    testRun.executeCommand(command);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment