WordHat

When you start a new project with Behat, perhaps the first things to think about – after integrating BDD into your workflow – will be getting browser automation working, and writing your first tests.

Otherwise, if you are unsure how to proceed, first check the FAQ and the other recipe pages in the menu. These will be added to when we receive repeat questions. If you encounter a bug, have a suggestion, or would like to help the project grow, please get in contact via Github or our Slack.

Browser automation

One of the fun things about using Behat is seeing it control your web browser and navigating your site. Behat relies on a library called Mink to interface with your web browser. Mink has its own driver system, with each driver supporting a different combination of browser features.

Some Mink drivers run headless web browsers (e.g. Goutte), and these tend to be the fastest, though notably, most do not support Javascript. WordHat’s sample configuration file is configured to use Selenium, which supports a broad range of browser features for most use cases. Selenium is fiddly to set up, so we recommend using vvo/selenium-standalone.

For tests requiring Javascript interactions, mark the scenario or feature with the @javascript tag.

Your first tests

To confirm your Behat set up is working, copy any one (or all!) of WordHat’s own tests from vendor/paulgibbs/behat-wordpress-extension/features/*.feature into your project’s features/ folder.

Run Behat with vendor/bin/behat, and the tests you copied should pass if everything is working.