Git Product home page Git Product logo

Comments (15)

jonathanjfshaw avatar jonathanjfshaw commented on August 15, 2024 1

As @ptmkenny expanded elsewhere in another issue:

The relevant part is this:

  extensions:
    Behat\MinkExtension:
      base_url: 'http://YOUR_MACHINE_IP:LANDO_APPSERVER_PORT_NUMBER'

You will need to use the IP address of the machine on the local network. You can get this from ipconfig /all run from cmd.exe as an Admin. Make sure to use the ip4 address for your local network, not for DockerNAT (the correct IP should be like 192.168...).

Also, you need to substitute the lando appserver port number, which you can get from lando info and then looking for the http port number for appserver.


I found that ipconfig did not give me a good IP address. To get the real one beginning 192.168 I needed to look in settings a detailed here: https://www.windowscentral.com/4-easy-ways-find-your-pc-ip-address-windows-10-s#ip_address_settings

from docs.

dustinleblanc avatar dustinleblanc commented on August 15, 2024

to run lando behat you'd need to define a tooling entry that used the appserver:

tooling:
  behat:
    service: appserver

from docs.

ptmkenny avatar ptmkenny commented on August 15, 2024

@dustinleblanc Thanks, I added that to my lando.yml and then ran lando rebuild.

Then I tried running lando behat, but I'm getting:

/bin/sh: 1: behat: not found

Windows 10 Pro, running from powershell.

from docs.

ptmkenny avatar ptmkenny commented on August 15, 2024

Ok, more info.

So far, I have been able to get lando behat running like this by specifying, in .lando.yml:

tooling:
  behat:
    service: appserver
    description: Run behat tests locally.
    cmd:
      - /app/vendor/bin/behat

Tests can be run using this .behat.yml:

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: http://mysite.lndo.site
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drupal'
      drupal:
        drupal_root: '/app/web'
      drush:
        root: '/app/web'

The command I am using is:

lando behat --config=tests/behat.yml

But, this results in an error when attempting to connect to localhost:

    And I am logged in as a user with the "administrator" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
      cURL error 7: Failed to connect to localhost port 80: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) (GuzzleHttp\Exception\ConnectException)
    │
    ╳  Unable to access the response before visiting a page (Behat\Mink\Exception\DriverException)
    │

So, the problem is that the behat drush extension is trying to connect to mysite.lndo.site on port 80. How do I fix this?

from docs.

ptmkenny avatar ptmkenny commented on August 15, 2024

Ok, so here is a solution. On Windows, apparently you need to give behat the IP address of the host (ipconfig /all) when running behat through docker like this:

base_url: http://192.168.x.x:32888

I can run the tests this way using lando behat.

from docs.

dustinleblanc avatar dustinleblanc commented on August 15, 2024

from docs.

pirog avatar pirog commented on August 15, 2024

@ptmkenny you might be able to get around this by hacking the windows hosts file as well.

Also would love to see this knowledge added to some of our behat docs if you've got the time for a PR!

from docs.

ptmkenny avatar ptmkenny commented on August 15, 2024

@pirog I've kept notes that I will clean up and turn into documentation later. Still trying to fix some issues; when I get it all working reliably, I'll add the doc.

from docs.

johnatasjmo avatar johnatasjmo commented on August 15, 2024

I have on behat-pantheon.yml

local:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2: ~
      base_url: 'http://nginx:80'
    Drupal\DrupalExtension:
      blackbox: ~
      api_driver: 'drupal'
      drupal:
        drupal_root: '/app/web'
      drush:
        root: '/app/web'

and run

lando behat --config=/app/tests/behat-pantheon.yml --profile local

and works for me.

from docs.

jonathanjfshaw avatar jonathanjfshaw commented on August 15, 2024

The IP address changes sometimes, perhaps when you move to a different wifi. So hardcoding an IP into behat.yml is a HORRIBLE workaround. I believe behat.yml does allow you to pick up environment variables, so maybe there's a way we could put the current ip into an environment variable and then put that variable into behat's base_url.

from docs.

dustinleblanc avatar dustinleblanc commented on August 15, 2024

So far, I have seen absolutely no issues on any platform with using the service hostname as the host for Behat. You should never have to make Behat look outside of docker's network to run any of these tests. Docker provides a private network for each app so that all services can find each other at unique hostnames defined by their service name. Just use http://nginx and move on with life. You don't need the internet or a proxy for this to work. I've done this with behat's defaults, I've done it with PhantomJS, I've done it with Chromedriver, just use the private network and life is easy no matter where the app ends up (local dev, CI, your buddy's laptop where they use a different proxy domain).

from docs.

pirog avatar pirog commented on August 15, 2024

from docs.

jonathanjfshaw avatar jonathanjfshaw commented on August 15, 2024

Ok, if I switch to via:nginx in my lando.yml then "http://nginx" works. However previously if I left the drupal8 recipe at its default, then "http://apache" didn't work. Thanks guys!

from docs.

dustinleblanc avatar dustinleblanc commented on August 15, 2024

👍 There will be some name for the service, lando info probably would show you 'appserver' or 'web' or something

from docs.

jonathanjfshaw avatar jonathanjfshaw commented on August 15, 2024

For anyone else finding in the future, the required host for the Drupal 8 recipe has now changed: it's http://appserver_nginx

from docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.