Principle:Getgauge Taiko Gauge Environment Configuration
| 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 argumentsTAIKO_BROWSER_PATH-- Path to a custom browser binaryTAIKO_NAVIGATION_TIMEOUT-- Default navigation timeout in millisecondsTAIKO_RETRY_TIMEOUT-- Default retry timeout in millisecondsTAIKO_HIGHLIGHT_ON_ACTION-- Toggle visual highlighting of elements during automationTAIKO_EMULATE_DEVICE-- Device model for viewport emulationTAIKO_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_ARGSwith 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 withgauge 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
--envflag. - 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
- Principle:Getgauge_Taiko_Gauge_Project_Setup -- Project scaffold that creates the env/ directory
- Principle:Getgauge_Taiko_Gauge_Step_Implementation -- Lifecycle hooks that consume configuration values
- Principle:Getgauge_Taiko_Gauge_Test_Execution -- Execution that selects the active environment