drupal/drupal-extension

Drupal extension for Behat

Maintainers

Package info

github.com/jhedstrom/drupalextension

Homepage

Type:behat-extension

pkg:composer/drupal/drupal-extension

Fund package maintenance!

jhedstrom

Statistics

Installs: 15 032 840

Dependents: 193

Suggesters: 0

Stars: 212

Open Issues: 56

v5.2.1 2026-03-08 05:27 UTC

This package is auto-updated.

Last update: 2026-03-16 05:08:22 UTC


README

Behat Drupal Extension Logo

Behat Drupal Extension

Latest Stable Version Total Downloads Latest Unstable Version License

ci GitHub Issues GitHub Pull Requests Documentation Status

The Drupal Extension is an integration layer between Behat, Mink Extension, and Drupal. It provides step definitions for common testing scenarios specific to Drupal sites.

Use it for testing your Drupal site.

If you're new to the Drupal Extension, we recommend starting with the Full documentation

Quick start

  1. Install using Composer:

    composer require --dev drupal/drupal-extension
  2. Create a file called behat.yml with a minimal configuration. For more information on configuration options, see Full documentation

    default:
      autoload: ['%paths.base%/tests/bootstrap']
      suites:
        default:
          paths: ['%paths.base%/tests/features']
          contexts:
            - Drupal\DrupalExtension\Context\DrupalContext
      extensions:
        Drupal\MinkExtension:
          browserkit_http: ~
          base_url: http://example.org/  # Replace with your site's URL
        Drupal\DrupalExtension:
          blackbox: ~
  3. Initialize Behat in your project:

    vendor/bin/behat --init
  4. Find pre-defined steps to work with using:

    vendor/bin/behat -di
  5. Optionally, define your own steps in tests/bootstrap/FeatureContext.php

  6. Start adding your feature files to the tests/features directory of your repository.

Available steps

Class Description
BatchContext Extensions to the Mink Extension.
ConfigContext Provides pre-built step definitions for interacting with Drupal config.
DrupalContext Provides pre-built step definitions for interacting with Drupal.
DrushContext Provides step definitions for interacting directly with Drush commands.
MailContext Provides pre-built step definitions for interacting with mail.
MarkupContext Extensions to the Mink Extension.
MessageContext Provides step-definitions for interacting with Drupal messages.
MinkContext Extensions to the Mink Extension.

Writing tests with AI assistants

Copy and paste below into your project's CLAUDE.md or AGENTS.md file.

## Writing Behat Tests

Available step definitions are listed in `STEPS.md`.
Read this file before writing or modifying Behat tests.
Use only step patterns from this file. Do not invent steps.

If `STEPS.md` does not exist or is outdated, regenerate it:

    vendor/bin/behat -di > STEPS.md

Regenerate after adding new Context classes or updating dependencies.

For detailed step documentation, see: vendor/drupal/drupal-extension/STEPS.md

Credits

Additional resources

Examples and code snippets

Release notes

See CHANGELOG.

Contributing

Features and bug fixes are welcome!

See CONTRIBUTING.md for more information.