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 Configuration Base

From Leeroopedia
Knowledge Sources
Domains Configuration, File_Parsing
Last Updated 2026-02-12 12:00 GMT

Overview

Concrete tool for loading, parsing, and managing TestCafe configuration options from JSON5 or JavaScript configuration files.

Description

The Configuration class is the abstract base class that loads configuration files (.testcaferc.json, .testcaferc.cjs, or .testcaferc.js), parses their contents via JSON5 or require, converts raw key-value pairs into Option objects stored in a dictionary, and supports merging options from multiple sources (file, CLI input, defaults) with deep-merge support and override tracking. It is extended by TestCafeConfiguration and TypescriptConfiguration for their specific behaviors.

Usage

This class is not directly instantiated by test authors. It forms the foundation for TestCafe's configuration system, supporting the .testcaferc.json configuration file and programmatic option merging.

Code Reference

Source Location

Signature

export default class Configuration {
    protected _options: Dictionary<Option>;
    protected _filePath?: string;
    protected readonly _defaultPaths?: string[];
    protected _overriddenOptions: string[];

    public constructor (configurationFilesNames: string | null | string[]);

    protected static _fromObj (obj: object): Dictionary<Option>;
    public getOption (name: string): OptionValue;
    public getOptions (): Dictionary<OptionValue>;
    public clone (): Configuration;
    public async init (): Promise<void>;
    public mergeOptions (options: Dictionary<OptionValue>): void;
    public mergeDeep (option: string, source: object): void;
    public setOptionValue (option: Option, value: OptionValue): void;
    protected async _load (): Promise<void>;
    protected _ensureOptionExists (name: string): void;
}

Import

import Configuration from './configuration/configuration-base';

I/O Contract

Inputs

Name Type Required Description
configurationFilesNames string or string[] or null Yes Configuration file names to search for (e.g., '.testcaferc.json')
options Dictionary<OptionValue> No External options to merge (from CLI or programmatic API)

Outputs

Name Type Description
getOption() OptionValue Returns the value of a named configuration option
getOptions() Dictionary<OptionValue> Returns all option values as a plain object
_filePath string Resolved path to the active configuration file

Usage Examples

// Internal usage when extending for TestCafe-specific config
import Configuration from './configuration/configuration-base';

class TestCafeConfiguration extends Configuration {
    constructor () {
        super(['.testcaferc.json', '.testcaferc.cjs', '.testcaferc.js']);
    }

    async init () {
        await super.init();
        // Apply defaults and validate
    }
}

const config = new TestCafeConfiguration();
await config.init();

// Get individual option
const concurrency = config.getOption('concurrency');

// Merge CLI options
config.mergeOptions({
    browsers: ['chrome:headless'],
    concurrency: 3,
});

Related Pages

Page Connections

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