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.

Principle:Getgauge Taiko Gauge Environment Configuration

From Leeroopedia
Field Value
Page Type Principle
Repository Getgauge_Taiko
Domains Testing, Configuration
Implemented By Implementation:Getgauge_Taiko_Gauge_Env_Properties

Overview

Mechanism for managing environment-specific test settings through property files and runtime configuration.

Description

Gauge supports multiple environments through property files stored in the env/ directory. The Taiko repository's functional test suite demonstrates this with three property files under test/functional-tests/env/default/:

default.properties -- Baseline framework configuration:

gauge_reports_dir = reports
overwrite_reports = true
screenshot_on_failure = true
logs_directory = logs
gauge_specs_dir = specs
csv_delimiter = ,

headless.properties -- Browser display mode control:

headless = true

js.properties -- JavaScript/TypeScript runner settings:

test_timeout = 240000
DEBUG = false

All properties defined in these files are available as environment variables during test execution. The hooks.ts file in the Taiko test suite reads the headless property directly:

const headless = process.env.headless.toLowerCase() === "true";

The configuration system operates at two levels:

  • Gauge property files -- Static configuration read at framework startup. Controls framework behavior (report directories, timeouts, spec directories).
  • Taiko setConfig() -- Runtime configuration applied in lifecycle hooks. Controls browser automation behavior (navigation timeout, retry timeout, observe mode). From hooks.ts:
@BeforeSuite()
public async beforeSuite() {
    await startServer();
    setConfig({ navigationTimeout: 60000 });
}

Additionally, Taiko supports its own environment variables that control browser behavior independently of Gauge:

  • TAIKO_BROWSER_ARGS -- Comma-separated browser launch arguments
  • TAIKO_BROWSER_PATH -- Path to a custom browser binary
  • TAIKO_NAVIGATION_TIMEOUT -- Default navigation timeout in milliseconds
  • TAIKO_RETRY_TIMEOUT -- Default retry timeout in milliseconds
  • TAIKO_HIGHLIGHT_ON_ACTION -- Toggle visual highlighting of elements during automation
  • TAIKO_EMULATE_DEVICE -- Device model for viewport emulation
  • TAIKO_EMULATE_NETWORK -- Network throttling profile (GPRS, Regular2G, Good3G, WiFi, etc.)

The Taiko config module (lib/config.js) reads these environment variables to set defaults:

const defaultConfig = {
    navigationTimeout: Number(process.env.TAIKO_NAVIGATION_TIMEOUT) || 30000,
    retryTimeout: Number(process.env.TAIKO_RETRY_TIMEOUT) || 10000,
    retryInterval: 100,
    observe: false,
    waitForNavigation: true,
    ignoreSSLErrors: true,
    headful: false,
    highlightOnAction: process.env.TAIKO_HIGHLIGHT_ON_ACTION
        ? process.env.TAIKO_HIGHLIGHT_ON_ACTION.toLowerCase() === "true"
        : true,
};

Usage

  • Configure different settings for local development (headful mode, longer timeouts, debug enabled) vs CI/CD (headless, strict timeouts, debug disabled).
  • Override browser arguments for containerized environments by setting TAIKO_BROWSER_ARGS with flags like --no-sandbox, --disable-dev-shm-usage, and --disable-gpu.
  • Create additional environment directories (e.g., env/ci/, env/staging/) to manage distinct configurations, and select them at runtime with gauge run --env ci.
  • Use setConfig() in @BeforeSuite() hooks for programmatic configuration that depends on runtime conditions.
  • Keep sensitive values (API keys, credentials) out of property files -- use CI/CD secret injection instead.

Theoretical Basis

The environment configuration system follows the Strategy Pattern applied to test infrastructure:

  • Each environment directory (env/default/, env/ci/) encapsulates a complete configuration strategy.
  • The Gauge runner selects the strategy at execution time based on the --env flag.
  • Default properties provide a fallback chain -- the env/default/ directory always loads, and environment-specific directories override individual properties.

This layered configuration approach follows the Twelve-Factor App principle of storing configuration in the environment. Properties become environment variables, making the test suite portable across execution contexts without code changes.

The dual-level configuration (Gauge properties + Taiko setConfig) separates framework concerns (where to store reports, which specs to run) from automation concerns (how long to wait for navigation, whether to run headless). This separation of concerns allows independent tuning of each layer.

Related Pages

Implemented By

Related Principles

Page Connections

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