I have an existing Drupal 8 project which I think meets the requirements in the setup documentation: I have the current version of drupal/drupal-extension installed with composer.

In the root folder of the project, I've created a behat.yml file as explained in the docs.

But when I do vendor/bin/behat --init I get this error:

In ExtensionManager.php line 194:

  `Drupal\MinkExtension` extension file or class could not be located.

Comments

joachim created an issue. See original summary.

danwallace101’s picture

I am getting exactly the same error. I have been trying to use behat on an existing site and have been getting different errors, so I though I'd first off get it working on a fresh installation of Drupal. In this fresh installation I am getting exactly the error you are describing.. Haven't yet worked out the issue though..

Sorry, just re-read, I'm not getting exactly the same error. I am seeing this:

In ExtensionManager.php line 194:
                                                                       
  `Behat\MinkExtension` extension file or class could not be located.  
jhedstrom’s picture

Can you post your behat.yml config?

joachim’s picture

My behat file is currnetly:

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
  extensions:
    Drupal\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: http://localhost/my-site/www  # Replace with your site's URL
    Drupal\DrupalExtension:
      blackbox: ~

Prior to that I had it looking like the example in https://behat-drupal-extension.readthedocs.io/en/3.1/localinstall.html

jhedstrom’s picture

Ah, I think the docs are out of sync with the 3.x branch. If you use the 4.x branch (in beta), this should work out I think.

joachim’s picture

I'm tied to version 3 by Acquia Lightning's composer requirements:

acquia/lightning_dev dev-8.x-1.x (requires drupal/drupal-extension ^3.4.0)

(I expect there is a way I could hack that, but I don't want to go down a rabbithole of fighting with Composer.)

Are there docs for the 3.x branch anywhere? There seems to be very little information in general on using Behat with Drupal -- I've only found 2 or 3 blog posts, for instance.

jhedstrom’s picture

It's weird they have that in require rather than require-dev. There are 3.x docs here: https://behat-drupal-extension.readthedocs.io/en/3.1/

brooke_heaton’s picture

Running into the same errors. I logged an issue on blt-require-dev. I'm not using lightening. Would love to not use BLT. But I do.

shwetaneelsharma’s picture

https://www.drupal.org/project/drupalextension/issues/3067930#comment-13...
Jhedstrom, I am using the Drupa Extension 4.x beta branch and still facing this issue.

shwetaneelsharma’s picture

I got this working by using the latest versions available for all Behat related dependencies.

samiullah’s picture

I also faced same issue:
Fix:

1. Create composer.json file
2. Run composer require "drupal/drupal-extension"
3. Run bin/behat --init command

If u have older version installed use composer remove command to remove that version

alex.skrypnyk’s picture

Status: Active » Closed (outdated)

This should be resolved in the latest version.
https://github.com/jhedstrom/drupalextension/releases/tag/v5.2.0

Please re-open in GitHub.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.