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:Nightwatchjs Nightwatch Gherkin Feature Syntax

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

Overview

Pattern specification for writing Gherkin .feature files used by the Cucumber test runner in Nightwatch.js.

Description

Gherkin .feature files use a structured natural language syntax parsed by @cucumber/cucumber. Each file starts with Feature: followed by a description, then one or more Scenario: blocks containing Given/When/Then steps. Tags (@tagName) on scenarios enable filtering. Step text is matched against regex patterns in step definitions.

Usage

Create .feature files in the configured feature_path directory. Write scenarios using Given/When/Then keywords that match step definitions.

Code Reference

Source Location

  • Repository: nightwatch
  • File: test/cucumber-integration-tests/sample_cucumber_tests/integration/sample.feature
  • File: test/cucumber-integration-tests/sample_cucumber_tests/parallel/sample.feature

Signature

@tag
Feature: Feature description
  As a [role]
  I want [goal]
  So that [benefit]

  @scenario-tag
  Scenario: Scenario description
    Given precondition step text
    When action step text
    Then expected outcome step text
    And additional condition

Import

# No import required - .feature files are discovered via feature_path config

I/O Contract

Inputs

Name Type Required Description
Feature: string Yes Feature title and description
Scenario: string Yes Scenario title
Given/When/Then string Yes Step text matching regex in step definitions
@tag annotation No Tags for filtering (e.g., @pass, @fail, @smoke)

Outputs

Name Type Description
Parsed scenarios Objects Feature and scenario objects passed to step definition matcher

Usage Examples

Basic Feature File

@search
Feature: Museum Search
  As a museum visitor
  I want to search the collection
  So that I can find specific artworks

  @smoke
  Scenario: Search for a painting
    Given I open the Rijksmuseum page
    And I dismiss the cookie dialog
    When I search "Rembrandt"
    Then the title is "Rijksmuseum - Results for 'Rembrandt'"
    And Body contains "Rembrandt"

  @regression
  Scenario: Empty search
    Given I open the Rijksmuseum page
    When I search ""
    Then the title is "Rijksmuseum"

Related Pages

Implements Principle

Page Connections

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