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 ReExecutablePromise

From Leeroopedia
Knowledge Sources
Domains Async_Patterns, Testing
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete Promise subclass that supports lazy execution and re-execution of its executor function, enabling TestCafe's selector and assertion retry mechanism.

Description

ReExecutablePromise extends Promise to add the ability to re-run its executor function on demand. Unlike a standard Promise which executes its executor once and caches the result, ReExecutablePromise can be re-triggered. This is the foundation of TestCafe's auto-retry mechanism: when a selector or assertion fails, the framework re-executes the underlying promise to try again. The promise is also lazy — it only begins execution when awaited.

Usage

This class is used internally by the Selector API and assertion system. When a user writes await Selector('.loading').exists, the selector check is wrapped in a ReExecutablePromise that can be retried until the timeout expires.

Code Reference

Source Location

Signature

export default class ReExecutablePromise extends Promise<any> {
    private _fn: Function;
    private _taskPromise: Promise<any> | null;

    constructor (executorFn: Function);

    public _ensureExecuting (): void;
    public _reExecute (): ReExecutablePromise;

    public then (onFulfilled?: Function, onRejected?: Function): ReExecutablePromise;
    public catch (onRejected?: Function): ReExecutablePromise;
}

Import

import ReExecutablePromise from '../utils/re-executable-promise';

I/O Contract

Inputs

Name Type Required Description
executorFn Function Yes Function to execute (and potentially re-execute)

Outputs

Name Type Description
Promise result any The resolved value from the executor function
_reExecute() ReExecutablePromise New promise that re-runs the executor

Usage Examples

import ReExecutablePromise from '../utils/re-executable-promise';

// Internal usage: wrapping a selector check for retry
const selectorPromise = new ReExecutablePromise(() => {
    return evaluateSelectorInBrowser('.loading');
});

// First execution
const result = await selectorPromise;

// Re-execute for retry
const retryResult = await selectorPromise._reExecute();

Related Pages

Page Connections

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