Skip to content

Installing WordHat


WordHat requires PHP (version 7.2+), Composer, and a WordPress site to test (version 4.8+).

We recommend using WP-CLI1 (version 2.1.0+).


  1. Create a folder for your tests. From a terminal:
    mkdir project
    cd project
  2. Tell Composer to download WordHat:
    composer require --dev paulgibbs/behat-wordpress-extension behat/mink-goutte-driver dmore/behat-chrome-extension
  3. Copy WordHat's sample configuration file into your project folder and rename it:
    cp vendor/paulgibbs/behat-wordpress-extension/behat.yml.dist behat.yml
  4. Edit your behat.yml and:

    • Update the base_url setting with the URL of the website that you intend to test.
    • Update the path setting with either the relative or absolute path to your WordPress' files.
    • Update the users section, and specify a username and password of an administrator user account in your WordPress.
    • If your WordPress is installed in a subdirectory, consult the FAQ for information about the site_url setting.
  5. Initialise Behat:
    vendor/bin/behat --init

    What does this do?

    This creates a features/ folder for your Features (tests), and a new Context class. These will come in handy later!

  6. To confirm that everything is set up correctly, run:
    vendor/bin/behat --definitions i
    If it worked, you will see a list of text that looks a little like the following (but much longer):
    Given I am an anonymous user
    Given I am not logged in
    Given I am logged in as a user with the :role role(s)
    Given I am logged in as :name

Next steps

Now that you have WordHat set up, we recommend reading our introduction to Behat to help you learn the basics before you start writing tests for your site.

  1. The WP-CLI executable must be named wp and be within your system’s $PATH