Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Workflow:Getgauge Taiko Gauge Integration Testing

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Acceptance_Testing, Test_Framework_Integration
Last Updated 2026-02-12 03:00 GMT

Overview

End-to-end process for setting up and running readable acceptance tests using Gauge as the test framework with Taiko as the browser automation engine.

Description

This workflow covers integrating Taiko with the Gauge test framework to write acceptance tests in Markdown specification format. Gauge provides test case management, parallel execution, data-driven testing, and HTML reporting. Taiko provides the browser automation layer through step implementations. The workflow starts from project initialization via `gauge init js`, proceeds through writing specifications and step implementations, and covers execution including Docker containerization for CI/CD. The REPL's `.step` command can generate Gauge step definitions directly from recorded browser interactions.

Usage

Execute this workflow when you need structured acceptance testing with human-readable specifications, parallel test execution, data-driven test scenarios, or integration with CI/CD pipelines that require HTML test reports. This is the recommended approach for teams that want business-stakeholder-readable test documentation backed by automated Taiko browser tests.

Execution Steps

Step 1: Initialize the Gauge Project

Install the Gauge CLI via npm and initialize a new JavaScript project using the Gauge template. This creates the standard directory structure with specification files, step implementation files, environment configuration, and a manifest. The template includes a sample specification and step implementation that demonstrates Taiko integration.

Key considerations:

  • `npm install -g @getgauge/cli` installs the Gauge runner
  • `gauge init js` creates the project structure with Taiko pre-configured
  • The TypeScript template is available via `gauge init ts` for TypeScript projects
  • The generated project includes a Dockerfile for containerized execution

Step 2: Write Gauge Specifications

Create Markdown `.spec` files in the `specs/` directory that describe test scenarios in natural language. Each specification contains a heading (test suite name), scenarios (individual test cases), and steps (individual actions prefixed with `*`). Steps use parameterized text that maps to step implementations.

Key considerations:

  • Specifications use Markdown format with `#` for suite names and `##` for scenario names
  • Steps are lines prefixed with `*` followed by a description
  • Parameters are enclosed in angle brackets or quotes within step text
  • Data tables can drive multiple iterations of the same scenario

Step 3: Implement Step Definitions

Write JavaScript (or TypeScript) step implementation files in the `tests/` directory that map specification steps to Taiko API calls. Each step function receives parameters from the specification and uses Taiko's browser automation APIs to perform the corresponding browser action. Before/after hooks manage browser lifecycle per suite or scenario.

Key considerations:

  • Use `step("step text with <param>", async (param) => {...})` to define implementations
  • Before/after suite hooks handle `openBrowser` and `closeBrowser`
  • Before/after scenario hooks can manage incognito contexts or page state cleanup
  • The Taiko REPL's `.step` command generates step definition code from recorded interactions

Step 4: Configure Environment Settings

Set up environment-specific configuration in the `env/` directory. Properties files control browser mode (headless vs headful), timeouts, and Taiko-specific settings. Multiple environment directories allow different configurations for local development, CI, and staging.

Key considerations:

  • `env/default/headless.properties` controls the default browser visibility
  • `env/default/js.properties` or `ts.properties` configures the step runner
  • Environment variables like `TAIKO_BROWSER_ARGS` and `TAIKO_BROWSER_PATH` override defaults
  • Custom environments are selected at runtime with `--env` flag

Step 5: Run Tests and Generate Reports

Execute the test suite using the `gauge run` command or `npm test`. Gauge discovers specifications, matches steps to implementations, executes them in order, and generates an HTML report. Parallel execution is supported for independent specifications. For CI/CD, run inside a Docker container using the project's Dockerfile.

Key considerations:

  • `gauge run specs/` executes all specifications in the directory
  • `gauge run --parallel` runs specifications concurrently for faster execution
  • HTML reports are generated in the `reports/` directory by default
  • The Gauge screenshot plugin integrates with Taiko's `screenshot` API for failure captures
  • Docker execution: `docker build -t gauge-taiko . && docker run --rm -v ${PWD}/reports:/gauge/reports gauge-taiko`

Execution Diagram

GitHub URL

Workflow Repository