Behat lets you write tests as plain-English scenarios, then runs them against your site:
Feature: Contact page
Scenario: Visitor finds the contact page
When I visit "/contact"
Then the response status code should be 200
And I should see the heading "Contact"Behat runs a step only when PHP code stands behind it. Behat Steps is that code, already written and tested. It ships steps that work on any website and steps that only mean something on a Drupal site. Every step is a thin wrapper over named helpers, which your own steps can call too.
- Web and Drupal steps for pages, forms, APIs, email, caches, content and more, with an example for each.
- Helpers behind every step, for the steps you write in your project's own words.
- Backends picked by capability, so a step runs in-process or through Drush.
- Support for Behat 3.33+ and Behat 4, Drupal 11 and 12, and PHP 8.3 to 8.5.
- BrowserKit, Selenium and Chrome DevTools browser drivers.
- Cleanup of the entities a scenario creates.
- Step and helper references in the package for AI coding agents, and a skill the agent follows to write your own steps on the helpers.
In your project's root, run the following command:
composer require --dev drevops/behat-steps:^4The command also installs Behat, Mink and the rest of what the steps run on. A few steps need a package of their own, which Behat Steps lists under suggest in its composer.json:
softcreatr/jsonpathandjustinrainbow/json-schemafor the JSON path and JSON schema steps.lullabot/mink-selenium2-driverordmore/behat-chrome-extensionfor@javascriptscenarios, which drive a real browser.
Follow the Quick start from here to a passing scenario. Installation covers the optional dependencies and the JavaScript browser drivers. New to Behat? Key concepts explains its moving parts in plain words.
MIGRATION.md lists the changes from 3.14 to 4.0, and an AI coding agent can apply them for you. Migrating from 3.x shows how.
The step and helper references ship with the package as STEPS.md and HELPERS.md, so a coding agent in your project reads them from vendor/drevops/behat-steps/. The create-behat-step skill ships beside them. Describe a step, and your agent writes it on the helpers, in a trait your own context uses. Writing tests with AI assistants has a snippet for your CLAUDE.md or AGENTS.md, and shows how to install the skill.
Contributions are welcome. CONTRIBUTING.md holds the rules for code in this repository and the local development setup. The documentation site's Contributing section walks through a code change and writing the docs.
This repository was created using the Scaffold project template
