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 RunnerAPI TypeDefs

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

Overview

Concrete TypeScript type declarations for TestCafe's programmatic API: the TestCafe, Runner, and TestCafeFactory interfaces.

Description

This file defines the core interfaces for TestCafe's Node.js programmatic API. TestCafeFactory is the factory function that creates a TestCafe instance. TestCafe provides createRunner(), createLiveModeRunner(), close(), and server info. Runner provides the fluent API with src(), browsers(), reporter(), screenshots(), video(), concurrency(), filter(), useProxy(), tsConfigPath(), compilerOptions(), and run() which returns a Promise resolving to the number of failed tests.

Usage

Import these types when using TestCafe's Node.js API to create and run tests programmatically from your own scripts.

Code Reference

Source Location

Signature

interface TestCafe {
    createRunner(): Runner;
    createLiveModeRunner(): Runner;
    close(): Promise<void>;
    readonly browserConnectionGateway: { connectUrl: string };
}

interface Runner {
    src(source: string | string[]): this;
    browsers(browser: string | string[]): this;
    reporter(name: string | ReporterOption | Array<string | ReporterOption>, output?: string | NodeJS.WritableStream): this;
    concurrency(n: number): this;
    filter(callback: (testName: string, fixtureName: string, fixturePath: string, testMeta: Record<string, string>, fixtureMeta: Record<string, string>) => boolean): this;
    screenshots(options: ScreenshotOptionValue): this;
    video(path: string, options?: VideoOptions, encodingOptions?: object): this;
    startApp(command: string, initDelay?: number): this;
    useProxy(host: string, bypassRules?: string | string[]): this;
    tsConfigPath(path: string): this;
    compilerOptions(opts: object): this;
    run(options?: Partial<RunOptions>): Promise<number>;
    stop(): Promise<void>;
}

interface TestCafeFactory {
    (hostname?: string, port1?: number, port2?: number, sslOptions?: TlsOptions, developmentMode?: boolean, retryTestPages?: boolean, cache?: boolean, configFile?: string): Promise<TestCafe>;
}

Import

import createTestCafe from 'testcafe';

I/O Contract

Inputs

Name Type Required Description
hostname string No Server hostname (default: localhost)
port1/port2 number No Server ports
source string or string[] Yes Test file paths or globs
browser string or string[] Yes Browser aliases (e.g., 'chrome:headless')

Outputs

Name Type Description
TestCafe instance TestCafe Framework instance with createRunner()
run() Promise<number> Number of failed tests (0 = all passed)

Usage Examples

import createTestCafe from 'testcafe';

async function runTests(): Promise<void> {
    const testcafe: TestCafe = await createTestCafe('localhost', 1337, 1338);

    const runner: Runner = testcafe.createRunner();

    const failedCount: number = await runner
        .src(['tests/**/*.ts'])
        .browsers(['chrome:headless', 'firefox:headless'])
        .reporter(['spec', { name: 'json', output: 'report.json' }])
        .screenshots({ path: 'screenshots/', takeOnFails: true })
        .video('videos/')
        .concurrency(3)
        .run({ skipJsErrors: true, selectorTimeout: 5000 });

    console.log(`Tests failed: ${failedCount}`);

    await testcafe.close();
}

runTests();

Related Pages

Page Connections

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